Created
August 27, 2019 14:55
-
-
Save BetterProgramming/3ae27a90aa9e75af33bad333e3293c45 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Post() | |
@UseInterceptors( | |
FileInterceptor('image', { | |
storage: diskStorage({ | |
destination: './files', | |
filename: editFileName, | |
}), | |
fileFilter: imageFileFilter, | |
}), | |
) | |
async uploadedFile(@UploadedFile() file) { | |
const response = { | |
originalname: file.originalname, | |
filename: file.filename, | |
}; | |
return response; | |
} | |
@Post('multiple') | |
@UseInterceptors( | |
FilesInterceptor('image', 20, { | |
storage: diskStorage({ | |
destination: './files', | |
filename: editFileName, | |
}), | |
fileFilter: imageFileFilter, | |
}), | |
) | |
async uploadMultipleFiles(@UploadedFiles() files) { | |
const response = []; | |
files.forEach(file => { | |
const fileReponse = { | |
originalname: file.originalname, | |
filename: file.filename, | |
}; | |
response.push(fileReponse); | |
}); | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment