Uploading files directly to Google Cloud Storage for GAE app

前端 未结 2 1732
醉梦人生
醉梦人生 2021-01-21 03:56

I am looking at switching from Blobstore to Google Cloud Storage for things like image uploads in a project (since Google calls Blobstore \"superseded\").

In Blobstore,

相关标签:
2条回答
  • 2021-01-21 04:25

    You can keep using the blobstore API but with actual storage in GCS, meaning same upload behaviour and probably minimal changes to your app.

    From Using the Blobstore API with Google Cloud Storage (Python):

    You can use the Blobstore API to store blobs in Cloud Storage instead of storing them in Blobstore. You need to set up a bucket as described in the Google Cloud Storage documentation and specify the bucket and filename in the blobstore.blobstore.create_upload_url gs_bucket_name parameter. In your upload handler, you need to process the returned FileInfo metadata and explicitly store the Google Cloud Storage filename needed to retrieve the blob later.

    A complete example app is presented there as well.

    Update: Oops, the above answer applies to the Python environment, the Java one follows:

    From Using the Blobstore API with Google Cloud Storage (Java):

    You can use the Blobstore API to store blobs in Cloud Storage instead of storing them in Blobstore. You need to set up a bucket as described in the Google Cloud Storage documentation and specify the bucket and filename in the BlobstoreService createUploadUrl, specify the bucket name in the UploadOptions parameter. In your upload handler, you need to process the returned FileInfo metadata and explicitly store the Google Cloud Storage filename needed to retrieve the blob later.

    There is no complete sample app for Java, tho.

    0 讨论(0)
  • 2021-01-21 04:37

    Google Cloud Storage does support generating URL for upload or reads. For more information see: https://cloud.google.com/storage/docs/access-control/create-signed-urls-program

    The gcloud-java-storage library can help with creating such signed URL.

    0 讨论(0)
提交回复
热议问题