Uploading image to amazon s3 using multer-s3 nodejs

[Update Mar 2022] It works perfectly fine till-date and now also shows the uploaded file public URL as well. Complete and working Node Cheat | Upload to s3 using multer-s3 available. Code: var express = require(‘express’), aws = require(‘aws-sdk’), bodyParser = require(‘body-parser’), multer = require(‘multer’), multerS3 = require(‘multer-s3’); aws.config.update({ secretAccessKey: ‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’, accessKeyId: ‘XXXXXXXXXXXXXXX’, region: ‘us-east-1’ … Read more

nodejs, multer, aws S3

Quick fixes: remain same const s3 = new AWS.S3({ accessKeyId: process.env.AWS_ID, secretAccessKey: process.env.AWS_SECRET, region: process.env.AWS_REGION }); the date and uuid variables both will initialize when node server start, it will never change until your node server restart, you just need to put it in to a function to return every time new file name, here … Read more