Home > OS >  how to store images on heroku
how to store images on heroku

Time:03-25

I Am trying to store images on Heroku server ./public.uploades folder but when I try to get images I get 404 not found is there any way to store images in Heroku other AWS s3

const storage = multer.diskStorage({
    destination:function(req,file,cb){
        cb(null,"./public/uploades")     //storage confg
   },
    filename: function (req, file, callback) {
        callback(null, file.fieldname   '-'   Date.now()   path.extname(file.originalname));
      }

})

const upload = multer({ storage:storage,limits: { fileSize: 5000000 }});

app.get("/fetchimage/", (req, res) => {
    const file = req.query.file
    const fileLocation = path.join('/public/uploades', file);
    res.sendFile(__dirname  fileLocation)
    })

CodePudding user response:

Heroku dose not allow any file excluding git. However you can use https://cloudinary.com for image upload its free.

  • Related