Do not display file in browser when using Google Cloud Storage: ALWAYS DOWNLOAD
-
13-12-2019 - |
Question
I just started using Google Cloud Storage with a Rails 3 app. I am able to successfully upload the file to my bucket using Carrierwave, but I want the file to ALWAYS DOWNLOAD when the link is clicked on and NEVER render directly in the browser.
I know that with Dropbox you can simply add "?dl=1" to the end of the download link and it will always download. Does Google Cloud Storage have any such URL convention? Thanks in advance.
Solution
After doing some further research it looks like you have to modify the HTTP header yourself for Content-Disposition.
https://developers.google.com/storage/docs/reference-headers#contentdisposition
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow