In the REST API below, what is the type of file object that is received.
@Post('/:folderId/documents/:fileName')
@UseInterceptors(FileInterceptor('file'))
@ApiConsumes('multipart/form-data')
@ApiImplicitParam({ name: 'folderId', description: ' Folder Id' })
@ApiImplicitParam({ name: 'fileName', description: ' File Name' })
@ApiImplicitFile({ name: 'file', required: true, description: 'PDF File' })
async uploadFile(@UploadedFile() file, @Param() folderId, @Param() fileName) {
/**
* I need to know the type of file object (first argument) of uploadFile
*/
this.folderService.uploadFile(file, folderId, fileName);
}
I need to write a file received in the request to disk. How to do that?
You can import the type from the package. '@types/multer'
and then qualify the file as:
@UploadedFile() file: Express.Multer.File,
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/multer/index.d.ts#L103
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With