Архив рубрики: AWS

Pre-Signed URL for Amazon S3 Object

It’s so easy enough than I thought before!

At first let’s upload file to chosen bucket. Below is a live example from my Laravel 5 project:

I’ve set ACL to ‘authenticated-read’ (it was ‘public-read’ before) because the aim of pre-signed URL is to restrict access and give it only to authorized users (who have valid link).

Then if we want to get actual download URL let’s get our S3 client:

Then get appropriate command:

Get request to execute this command:

And finally get the pre-signed Url to download private resource!

I’m using a kind of download controller that acts as proxy of user request to download a private file so the result of its work is a redirect to actual resource URL: