How to Upload File to AWS S3 Using Express.js?

Utkarsha Bakshi
Geek Culture
Published in
4 min readFeb 18, 2023

--

Source (link)

In this short post, I will show you how to upload files to AWS S3 using express-fileupload in Express.js application. We will use aws-sdk client library to upload the file to the bucket.

If you are looking to upload images to S3 using NextJS, refer to this article.

Let us jump right into it and learn how it can be done.

Step 0: Create AWS Access Key and Secret

First, create an AWS access key and secret with access to AWS S3 putObject IAM permissions.

https://aws.amazon.com/premiumsupport/knowledge-center/create-access-key/

Step 1: Install Dependencies

Install the @aws-sdk/client-s3 library using NPM install command.

npm install @aws-sdk/client-s3

Also, install the express-fileupload package. express-fileupload is a simple Express.js middleware for uploading files.

npm install express-fileupload

--

--