我正试图找出一种使用Google App Engine将图像上传到Google Cloud 端存储的方法 .
我检查过:
Sending images to google cloud storage using google app engine
Upload images/video to google cloud storage using Google App Engine
他们都展示了如何使用BlobStore API来完成它 .
当我检查BlobStore API时:https://cloud.google.com/appengine/docs/python/blobstore/
他们提供了使用Google Cloud 端存储的说明 . BlobStore的当前状态是什么,将来是否会得到支持?
我看到了一个图像上传示例:https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/blobstore/main.py使用BlobStore API .
是否有使用Google App Engine的Google Cloud 端存储示例?
3 回答
通过App Engine上传图像有三个问题:
首先,效率非常低 . 您正在使用App Engine实例时间将数据从用户的浏览器传递到Google Cloud 端存储 .
其次,它更慢(再次,因为你使用中介) .
最后,App Engine不支持流式传输,所有请求都限制为32MB .
最好的选择是使用upload options之一将文件直接上传到 Cloud 存储 .
我最终使用https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/app-engine-cloud-storage-sample(GCS客户端@ChrisC73指出 .
另外,提到@vocausa的signed_url项目:https://github.com/voscausa/appengine-gcs-signed-url
我赞成上述答案,因为您应尽量避免通过App Engine传递数据 . 如果您确实需要将图像(或任何其他数据)从App Engine上传到使用Python的Google Cloud 端存储,那么答案就是ChrisC73指出要使用GoogleAppEngineCloudStorageClient,因为Python上没有内置的 Cloud 存储API运行 .
相比之下,PHP运行时具有built-in support for Google Cloud Storage,具有标准文件系统功能 .