Skip to content
Snippets Groups Projects
Commit 35607bb0 authored by Ivan Alglave's avatar Ivan Alglave
Browse files

possible fix for pdf files upload

parent a1a92094
No related branches found
No related tags found
1 merge request!15Upload fix
...@@ -60,13 +60,19 @@ export class InternshipsController { ...@@ -60,13 +60,19 @@ export class InternshipsController {
// uploads even if invalid state... // uploads even if invalid state...
@Put(':studentId/:state') @Put(':studentId/:state')
@UseInterceptors( @UseInterceptors(
FileInterceptor('pdf', { FileInterceptor('file', {
storage: diskStorage({ storage: diskStorage({
destination: './files', destination: './files',
filename: (_req, _file, cb) => { filename: (_req, _file, cb) => {
return cb(null, `${v4()}.pdf`); return cb(null, `${v4()}.pdf`);
}, },
}), }),
fileFilter: (req, file, cb) => {
if (!file.originalname.match(/\.pdf$/)) {
return cb(new Error('Only PDF files are allowed!'), false);
}
cb(null, true);
},
}), }),
) )
updateState( updateState(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment