Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS S3 Prevent Files From Being Download From Browser URL

I have an AWS S3 bucket, I want a majority of my files to be accessible via a url (my images and video links, etc) - This is already being accomplished. I have other files that I DO NOT want to have accessible from a URL, these would be audio files (mp3, wav, flac etc.). I only want users to be able to access my audio files by a php script serving them to the browser. More or less, I dont want user to have access to these files by guessing the URL of my AWS bucket where the files reside.

I'm stumped. Can anyone point me in the right direction. Thanks.

like image 264
LargeTuna Avatar asked Apr 05 '16 20:04

LargeTuna


1 Answers

You can make the files private and generate signed URLs to allow someone temporary access to the files: Share an Object with Others

Or you can set a policy to restrict people from accessing the files directly, only allowing them to access a file if it was linked from your website: Restricting Access to a Specific HTTP Referrer

Or you can serve those files by sending them through your PHP script, i.e. download the file to your PHP server and returning the file contents from there. In which case you can just make those files private in S3 or even move them to a separate bucket that is completely private. I don't recommend this method because it puts more load on your server.

like image 121
Mark B Avatar answered Nov 10 '22 08:11

Mark B