Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force download files from a google storage bucket instead of opening it it browser?

I have some audio files in a Google Bucket, and I am serving links to those file in a WordPress website.

How do I force download those files instead of playing in the browser.

Adding &response-content-disposition=attachment; to the end of the url doesn't work.

Tried in gsutil gsutil setmeta -h 'Content-Disposition:attachment' gs://samplebucket/*/*.mp3 I get the error

CommandException: Invalid or disallowed header (u'content-disposition).

Only these fields (plus x-goog-meta-* fields) can be set or unset: [u'cache-control', u'content-disposition', u'content-encoding', u'content-language', u'content-type']`


1 Answers

You can do this by editing object metadata, defining attachment into the Content-Disposition field

like image 111
claudod Avatar answered Oct 29 '25 05:10

claudod