I'm trying to access the buffer of a file uploaded with Postman to a simple controller in Nest. The buffer exists in the request object, but I can't access it in the fileFilter
of the FileInterceptor
.
Example:
@Post('file')
@UseInterceptors(FileInterceptor('file'))
async testUpload(@UploadedFile() file) {
// defined!
console.log(file.buffer)
}
But when I try and access the file from the interceptor the buffer isn't present
@UseInterceptors(FileInterceptor('file', {
fileFilter: (req, file, cb) => {
// undefined
console.log(file.buffer)
cb(null, true)
}
}))
async testUpload(@UploadedFile() file) {
// defined!
console.log(file.buffer)
}
Am I missing something here?