I have built an app in Nodejs which uploads file to the DigitalOcean Spaces. I am using multer for the same. When I run it locally on my device, it successfully uploads on DigitalOcean but when I try to upload it after the deploying the app on DigitalOcean, it gives me 404 not found and the above error. I have also uploaded the .aws folder which contains the access key and the secret key and also config file. What do I do?

const aws = require('aws-sdk');
const express = require('express');
const multer = require('multer');
const multerS3 = require('multer-s3');

const app = express();
const spacesEndpoint = new aws.Endpoint('nyc3.digitaloceanspaces.com');
const s3 = new aws.S3({
  endpoint: spacesEndpoint,

});



const upload = multer({
  storage: multerS3({
    s3: s3,
    bucket: 'imagebr',
    acl: 'public-read',

    key: function (request, files, cb) {

      cb(null, files.originalname);
    }
  })
}).single("image");

app.use(express.static('public'));

app.post('/uploads',upload,(req, res) => {
  res.send('uploaded');
})
app.listen(3001, function () {
  console.log('Server listening on port 3001.');
});     
0

There are 0 best solutions below