一些 Google App Engine BlobStore 问题
我已经在 Google App Engine 官方网站上搜索并阅读了有关 BlobStore 的文档,但有一些问题我仍然不明白。我的平台是webapp。
我读过的文档:
阅读所有这些文档后,我仍然遇到一些问题:
在 Blobstore Python API 概述 它表示:Blobstore 数据的最大大小应用程序通过一次 API 调用可以读取的大小为 1MB。这意味着什么?此 1MB 限制是否适用于
<块引用>sendblob()
?以网络应用 Blobstore 处理程序中的以下代码为例:类 ViewPhotoHandler(blobstore_handlers.BlobstoreDownloadHandler): def get(self, photo_key): self.send_blob(photo_key)
这是否意味着与
photo_key
关联的照片(上传并存储在 blobstore 中)必须小于 1MB?从上下文来看,我不这么认为。我认为照片可以有2GB大。但我不确定。send_blob()
上的 ContentType 是如何确定的?是文本/html 还是图像/jpeg?我可以自己设置某个地方吗? 网络应用 Blobstore 处理程序的以下解释非常令人困惑。对于不会说英语的人来说相当困难。有人可以用代码示例来解释它吗?send_blob()
的文档在哪里?我找不到它。send_blob() 方法接受 save_as 参数,该参数确定 blob 数据是作为原始响应数据还是作为带有文件名的 MIME 附件发送,这会提示 Web 浏览器使用给定名称保存文件而不是显示它。如果参数的值是字符串,则 blob 将作为附件发送,并且字符串值将用作文件名。如果 True 并且 blob_key_or_info 是 BlobInfo 对象,则使用该对象中的文件名。默认情况下,blob 数据作为响应正文而不是 MIME 附件发送。
有一个文件 http://www.example.com/example.avi 其中是20MB甚至2GB。我想从互联网获取 example.avi 并将其存储在 BlobStore 中。我检查过,urlfetch 请求大小限制为 1MB。我搜索并没有找到解决方案。
多谢!
I have googled and read the docs on Google App Engine official site about BlobStore but there are some problems that I still dont understand. My Platform is webapp.
Docs I have read:
After reading all these docs, I still have some problems:
In Blobstore Python API Overview it says: maximum size of Blobstore data that can be read by the app with one API call is 1MB. What does this mean? Does this 1MB limit apply to
sendblob()
? Take the following code from webapp Blobstore Handlers as an example:class ViewPhotoHandler(blobstore_handlers.BlobstoreDownloadHandler): def get(self, photo_key): self.send_blob(photo_key)
Does that mean the photo ( which is uploaded and stored in the blobstore )associated with the
photo_key
must be less than 1MB? From the context, I dont think so. I think the the photo can be as large as 2GB. But I am not sure.How is the ContentType determined on
send_blob()
? Is it text/html or image/jpeg? Can I set somewhere it myself? The following explanation from webapp Blobstore Handlers is so confusing. Quite difficult for a non-english speaker. Can someone paraphrase it with code samples? Where is the docs forsend_blob()
? I cant find it.The send_blob() method accepts a save_as argument that determines whether the blob data is sent as raw response data or as a MIME attachment with a filename, which prompts web browsers to save the file with the given name instead of displaying it. If the value of the argument is a string, the blob is sent as an attachment, and the string value is used as the filename. If True and blob_key_or_info is a BlobInfo object, the filename from the object is used. By default, the blob data is sent as the body of the response and not as a MIME attachment.
There is a file http://www.example.com/example.avi which is 20MB or even 2GB. I want to fetch example.avi from the internet and store it in the BlobStore. I checked, the urlfetch request size limit is 1MB. I searched and hadnt found a solution.
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
send_blob()
不涉及您的应用程序从 API 读取文件,因此 1MB 限制不适用。将响应返回给用户的前端服务将读取整个 blob 并在响应中返回所有内容(它很可能以块的形式进行读取,但这是您不必担心的实现细节。< /p>send_blob()
将内容类型设置为 Blob 的内部存储类型,或者您使用send_blob()
的可选content_type
参数指定的类型,似乎需要 RTFS;google.appengine.ext.webapp.blobstore_handlers
包。)确实没有很好的解决方案可以从网络获取任意文件并将其存储在 Blobstore 中。您很可能需要在其他地方(例如您自己的计算机或 EC2 实例)运行一个服务来获取文件并将它们发布到应用程序中的 blobstore 处理程序。
send_blob()
doesn't involve your application reading the file from the API, so the 1MB limit doesn't apply. The frontend service that returns the response to the user will read the entire blob and return all of it in the response (it most likely does the reading in chunks, but this is an implementation detail that you don't have to worry about.send_blob()
sets the content type to either the Blob's internal stored type, or the type you specify with an optionalcontent_type
parameter tosend_blob()
. For the documentation, it seems to need to RTFS; there's a docstring (in thegoogle.appengine.ext.webapp.blobstore_handlers
package.)There's really no great solution for fetching arbitrary files from the web and storing them in Blobstore. Most likely you'd need a service running elsewhere, like your own machine or an EC2 instance, to fetch the files and POST them to a blobstore handler in your application.