3
votes

I'm using JAVA Blobstore API to upload files directly to the GCS. I have followed this

https://cloud.google.com/appengine/docs/java/blobstore/#Java_Using_the_Blobstore_API_with_Google_Cloud_Storage

This is working seamlessly. But when I tried to view or download the file, from GCS, its actually showing a different name than I uploaded. Its happening while uploading itself. I think, It takes a random blobkey as file name.

Is there any way to change the filename in GCS after uploading programatically, or any way to upload with custom name using Blobstore API.

Any help would be greatly appreciated.

Thanks.

1

1 Answers

3
votes

It's not possible to set the name for files uploaded to GCS via Blobstore API. Direct object renaming is not possible on GCS. As a workaround you can:

  1. Get object name from returned FileInfo.
  2. Copy object to a new object of desired name.
  3. Delete old object.