google-cloud-platformgoogle-cloud-storagegsutil

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']`


Solution

  • as pointed by robsiemb, I had to invoke these commands under google cloud shell . In my case Windows shell turned out to be the culprit.