4
votes

I am trying to figure out a way to upload an image into Google Cloud Storage using Google App Engine.

I have checked:

Sending images to google cloud storage using google app engine

Upload images/video to google cloud storage using Google App Engine

They all show how to do it using the BlobStore API.

When I checked the BlobStore API:https://cloud.google.com/appengine/docs/python/blobstore/

They have a note to use Google Cloud Storage instead. What's the current status of BlobStore and will it be supported in the future?

I see an example for image upload: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/blobstore/main.py using BlobStore API.

Is there an example for Google Cloud Storage using Google App Engine?

3

3 Answers

6
votes

Uploading images through App Engine has three problems:

First, it's very inefficient. You are using your App Engine instance hours to simply pass-through data from a user's browser to Google Cloud Storage.

Second, it's slower (again, because you use an intermediary).

Finally, App Engine does not support streaming and all requests are limited to 32MB.

The best option is to upload files directly to Cloud Storage using one of the upload options.

2
votes
0
votes

I upvoted the above answer as you should try to avoid passing data through App Engine if possible. If you really need to upload an image (or any other data) from App Engine to Google Cloud Storage in Python, the answer is as ChrisC73 pointed out to use the GoogleAppEngineCloudStorageClient, as there is no built-in API for Cloud Storage on the Python runtime.

In contrast, the PHP runtime has built-in support for Google Cloud Storage with the standard filesystem functions.