Skip to content
Snippets Groups Projects
Unverified Commit 433a2532 authored by Ivan Alglave's avatar Ivan Alglave Committed by GitHub
Browse files

Merge pull request #15 from ivanalglave/upload-fix

Upload fix
parents c930f7ea e04359f4
No related branches found
No related tags found
No related merge requests found
......@@ -60,13 +60,19 @@ export class InternshipsController {
// uploads even if invalid state...
@Put(':studentId/:state')
@UseInterceptors(
FileInterceptor('pdf', {
FileInterceptor('file', {
storage: diskStorage({
destination: './files',
filename: (_req, _file, cb) => {
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(
......
......@@ -19,7 +19,7 @@ export class ResourcesController {
@Param('filename') filename,
@Res({ passthrough: true }) res: Response,
): StreamableFile {
const filepath = `files\\${filename}`;
const filepath = `files/${filename}`;
if (!existsSync(filepath)) throw NOT_FOUND;
const file = createReadStream(filepath);
res.set({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment