I use multer to manage uploaded file:
@Post('upload') @UseInterceptors(FilesInterceptor("images", 10, {
dest: "./uploads",
}))
uploadMultiple(@UploadedFiles() files) {
console.log(files, 'test');
}
I try to add a file extension to my uploaded files as:
@Post('upload') @UseInterceptors(FilesInterceptor("images", 10, {
dest: "./uploads",
filename: function (req, file, cb) {
cb(null, Date.now() + '.jpg') //Appending .jpg
}
}))
But when I do this I get an error:
TS2345: Argument of type '{ dest: string; filename: (req: any, file: any, cb: any) => void; }' is not assignable to parameter of type 'MulterOptions'. ??Object literal may only specify known properties, and 'filename' does not exist in type 'MulterOptions'
How to specify file extension to my uploaded files?
question from:
https://stackoverflow.com/questions/65891450/manage-uploaded-image-in-nest-js 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…