0
votes

I have images, videos, audio, and other types in my firebase storage and I want users to be able to click on a download button and download the file to their computer.

I have looked through firebase docs and cannot seem to find a way to do this.

I have tried changing attribute to "download" but all it does is go to the URL given by firebase storage.

Is this even possible with firebase storage to allow users to download a file to their computer?

1

1 Answers

1
votes

You'll need to look to enable CORS headers to allow for customers to make AJAX requests to your Firebase account and download files via their browser.

CORS Configuration To download data directly in the browser, you must configure your Cloud Storage bucket for cross-origin access (CORS). This can be done with the gsutil command line tool, which you can install from here.

If you don't want any domain-based restrictions (the most common scenario), copy this JSON to a file named cors.json:

[ { "origin": ["*"], "method": ["GET"], "maxAgeSeconds": 3600 } ]

Run gsutil cors set cors.json gs:// to deploy these restrictions.

https://firebase.google.com/docs/storage/web/download-files