With fileupload we can get tempfilepath but with multer any way to get tempfile path?I want to upload files to cloudinary using temp file path.. Here is my code.
const storage = multer.diskStorage({
destination: (req, file, cb)=>{
cb(null, 'uploads')
},
filename: (req, file, cb)=>{
cb(null, Date.now() + file.originalname)
},
useTempFiles: true
})
const upload = multer({storage});
app.post("/upload", upload.single('photo'), (req, res, next)=>{
let fileinfo = req.file;
console.log(fileinfo);
cloudinary.uploader.upload(fileinfo.tempFilePath,{width: 70, height: 90, crop: "fit"}, (err,result)=>{
console.error(err);
console.log(result.url);
});
})
const storage = multer.diskStorage({
filename: (req, file, cb)=>{
cb(null, Date.now() + file.originalname)
}
})
const upload = multer({storage});
app.post("/upload", upload.single('photo'), (req, res,
next)=>{
let fileinfo = req.file;
console.log(fileinfo);
cloudinary.uploader.upload(fileinfo.path,{width: 70,
height: 90,crop: "fit"}, (err,result)=>{
console.error(err);
console.log(result.url);
});
})
Make this changes to your code and try this