Node.js RestAPIs upload file to Amazon S3 | using Express, Multer, AWS-SDK


In the tutorial, we show how to build a Node.js/Express RestAPIs to Upload Files to Amazon S3 using Multer middleware and AWS-SDK.

Related posts:
Node.js/Express – PostgreSQL example – Upload File/Download File – Multer + Sequelize CRUD
NodeJS/Express – Bootstrap Image example
Mongoose Many-to-Many related models with NodeJS/Express, MongoDB

Related pages:


  • Node.js
  • Express
  • Multer
  • Amazon S3




We create a Node.js project as below ->


Expose a RestAPI: '/api/file/upload'

Upload File ->


Amazon S3 ->



Setting up Node.js project

Create a folder NodejsUploadFileAmazonS3, then init Node.js project ->

Install Express, Multer, AWS-SDK ->

-> package.json file:

Multer Config

– Create ./app/config/multer.config.js file:

AWS S3 Config

– Create a file ./app/config/s3.env.js ->

– Configure S3 Client in a file ./app/config/s3.config.js ->

Express Routers

– Create router in file ./app/routers/upload.router.js ->

Upload Controller

– Implement S3 Uploader in a controller file ./app/controllers/aws.controller.js ->


server.js file ->


Use npm install to install all dependencies before run the Node.js server with cmd npm start.


By grokonez | August 25, 2018.

Related Posts

2 thoughts on “Node.js RestAPIs upload file to Amazon S3 | using Express, Multer, AWS-SDK”

  1. Hi ,
    I done same thing, in my windows machine ,
    but i got a error like “cannot read property ‘originalname’ of defined.
    can you please help me on this.

  2. Perfect, It is working for single file upload but I need to upload multiple files. And I approached this method upload.array(“file”, 3) but it is giving error Cannot read property ‘original name’ of undefined would you please help me to figure out this.

Got Something To Say:

Your email address will not be published. Required fields are marked *