Search code examples
google-app-enginegoogle-cloud-storageblobstore

How to upload files to custom folder in AppEngine with blobstore and google cloud storage


I am using Google AppEngine. I am using the blobstore to upload files to Google Cloud Storage. (I can't upload to Cloud Storage directly because of request size restriction of AppEngine.)

I could upload to Google Cloud Storage. But I couldn't specify the folder to upload. So every file is being stored in the root folder.

Can anybody tell me how to upload to a specific folder?

I use the code from https://github.com/crhym3/java-blobstore-gcs-sample


Solution

  • It comes out that you can pass a "folder" name with a bucket name into .withGoogleStorageBucketName() method, like:

    UploadOptions uploadOptions = UploadOptions.Builder
         .withGoogleStorageBucketName("bucket_name/folder_name");