I need to perform the processing (in async upload) after the file has been uploaded, to which I'm getting error. At first I was using diskStorage instead of cloud to which my code was running correctly.
//Initial code that saved files to disk
@UseInterceptors(FileInterceptor('file', {
storage: diskStorage({
destination: './uploads', filename: (req, file, cb) => {
const randomName = Array(32).fill(null).map(() => (Math.round(Math.random() * 16)).toString(16)).join('')
cb(null, `${randomName}${extname(file.originalname)}`)
}
})
}))
//changed code which stores file to cloud
@UseInterceptors(FileInterceptor('file', {
storage: multerS3({
s3: s3,
bucket: 'uploads',
key: function (req, file, cb) {
console.log(file);
cb(null, file.originalname); //use Date.now() for unique file keys
}
})
}))
//the further processing reqd
async upload( @UploadedFile() file){
try {
...somecode
}
catch (error) {
throw new Error(error);
}
}
It gives error, "Error: File does not exist. Check to make sure the file path to your csv is correct." What could be the possible reason?