How-to: Upload Files to Amazon S3 via an API
Amazon S3 is a highly-utilized and well-known object storage service offered by Amazon Web Services (AWS). It is virtually used for everything, from storing data related to application logs, to gigabyte-sized media files.
Manually Upload to S3? Nah, ain’t nobody got time for that… 👎
But, what if… instead of manually navigating to our bucket, we upload objects into it through invoking an API? 😃
API to the rescue! 🦸
Having an API to upload data into S3 will enable:
- LESS manual work 💪
- Consumer-friendly interaction
- Quicker process to upload
Let’s go build our API!
We will be building our file upload solution using the following AWS Services:
High-Level Solution Architecture
Step 1 — Create an IAM Role with the required policy permissions
This role will consist of a policy that will allow our API to upload files into our S3 Bucket through an API Gateway endpoint.
Make sure your policy looks similar to what I have shared below:
Step 2 — Create the API Gateway
Now, we are going to a create an API Gateway that will be the entry to our File Uplaod API.
As shown below, the folder and file resources here represent our S3 Bucket and S3 Object respectively.
These resources will serve as parameters that we will specify as part of the PUT request endpoint/URL by the client.
Step 3 — Deploy the API and Call it!
Check out our S3 Bucket:
Want to learn more about Data Engineering? AWS Cloud?
Check out my series listed below! 🙂