AWS S3 is an object-storage service from Amazon Web Services, allowing you to store files online around the world. For all intents and purposes, it’s infinitely scalable and fully managed – meaning you can upload objects without any setup or management burden. Think of it as a turbo-charged, pay-as-you-go FTP server that’s managed for you. There’s plenty of Desktop Clients that support it, plus you can access it programatically using their API or SDK.

Typically you need an access key and secret key to do anything with S3, although you can create pre-signed access credentials to allow someone else to perform a specific action on your behalf. This is called pre-signing.

If you are using S3 with PHP, you may wish create pre-signed upload requests so third-parties can directly upload to your S3 bucket with these special restricted credentials. You may also wish to allow people to directly download files using a similar method.

S3 Pre-Sign Upload Code

This PHP code allows you to create these pre-signed uploads, restricting the user to only uploading specifically named files:

The beauty of this code is that it doesn’t require the AWS SDK for PHP. It’s fully standalone – making it perfect for anyone who just wants to do some pre-signing and nothing else. It’s based on the AWS-provided specification.

Of course, if you want to use the SDK you can still do that. Here’s the official docs.

You can upload directly from a HTML Form in an end-user’s browser, using the required fields.

You could also upload server-side, or in a desktop-app, using a simple Python request:

 

S3 Pre-Signed Download Code

You can also pre-sign downloads, allowing others to download one of your files for a limited time. Here’s some standalone PHP code that can create the pre-signed GET URL: