google-cloud-storagegoogle-api-java-client

Upload same name files to google cloud storage then download them with original names


So in google-cloud-storage if you upload more than one file with the same name to it the last will overwrite what was uploaded before it.

If I want to upload more than one file with the same name I should append some unique thing to the file name e.g. timestamp, random UUID.

But by doing so I'll lose the original file name while downloading, because I want to serve the file directly from google.


Solution

  • If we used the unique identifier as a folder instead of appending it to the file name, e.g. UUID +"/"+ fileName then we can download the file with its original name.