Amazon S3 - Forcing files to download
Sometimes your web browser will try to display or play whatever file you're downloading, and you might end up playing music or video inside your browser, instead of saving it. There are a variety of things that can be done to prevent this, and force the save option, but if you're storing your files on Amazon S3 then any settings on your web server are ignored.
Instead of relying on the settings of your web server you must set things properly in S3. Here's how they should be set.
- In your S3 Bucket find the file you wish to work with and click it.
- Click on the "Properties" tab
- Click on the box that says "Metadata"
- Click on the circle to the left of the Content-Type and then click "Add Metadata"
- Set the "Key" to "Content-Disposition" and set the value to "attachment" and hit save.
This will force it to be downloaded instead of played or displayed in your browser.