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
Branches
No related tags found
1 merge request!15Upload fix
This commit is part of merge request !15. Comments created here will be created in the context of that merge request.
...@@ -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.
Please to comment