ssk
ssk

Reputation: 9265

How to upload images to Google Cloud Storage using Google App Engine?

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?

Upvotes: 5

Views: 5214

Answers (3)

ssk
ssk

Reputation: 9265

I ended up using https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/app-engine-cloud-storage-sample (The GCS client @ChrisC73 pointed out.

Also, referred to @vocausa's signed_url project: https://github.com/voscausa/appengine-gcs-signed-url

Upvotes: 3

Adam
Adam

Reputation: 6015

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.

Upvotes: 1

Andrei Volgin
Andrei Volgin

Reputation: 41100

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.

Upvotes: 6

Related Questions