Upload to AWS S3 Using a Node.js Script or AWS Lambda

How to upload files to AWS S3 or Lambda using a Node.js script

Michael Whittle
The Startup

--

Licenced Image from Adobe Stock

I’ve been working through the AWS SDK for S3 trying to make sense of it. It’s definitely not straight forward and lacking some decent complete examples. Anyway, I’ve figured out how to upload an object to S3 using Lambda and also using a Node.js script and thought I would share it with all of you. Now that I can upload objects with Lambda as per my other article React.js API calls to AWS Lambda, API Gateway and dealing with CORS this also means I’m able to initiate this from React.js via API Gateway.

So let’s start from the beginning…

The first step is to create an S3 bucket in the AWS Management Console. For the purpose of this tutorial I just created a temporary S3 bucket called “mediumtutorial” in EU (Ireland) region, also referred to as “eu-west-1”. Just select all the default options, by clicking Next, Next, Next and Create Bucket.

The next step is to open your S3 bucket, click on the Permissions tab, then CORS configuration.

--

--

Michael Whittle
The Startup

Solution Architect — CCIE R&S #24223 | Full-Stack / Blockchain / Web3 Developer | Security Specialist | PyCryptoBot Creator