Skip to content
Snippets Groups Projects

Upload fix

Merged GUVEN Kemal requested to merge upload-fix into master
2 files
+ 8
2
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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(
Loading