Bladeren bron

RETURN the res.403 in failed sanitize

master
Rich Brown 1 jaar geleden
bovenliggende
commit
2d67b9e562
1 gewijzigde bestanden met toevoegingen van 1 en 3 verwijderingen
  1. +1
    -3
      routes/createRouter.js

+ 1
- 3
routes/createRouter.js Bestand weergeven

@@ -12,10 +12,8 @@ const storage = multer.diskStorage({
const { originalname } = file;
const fiver = Math.random().toString(36).substr(2, 5);
const ext = path.extname(originalname);
console.log(ext);
const rootName = originalname.replace(ext, '');
const newFilename = `${rootName}-${fiver}${ext}`;
console.log(newFilename);
cb(null, newFilename);
},
});
@@ -33,7 +31,7 @@ const sanitizedFile = (file) => {
createRouter.post('/form', upload.single('file'), (req, res) => {
const { file, body: { title, body, arrayOfTags } } = req;
if (!sanitizedFile(file)) {
res.status(403).json({ error: 'not an allowed filetype', url: null });
return res.status(403).json({ error: 'not an allowed filetype', url: null });
}
return req.app.locals.mp
.create(


Laden…
Annuleren
Opslaan