Browse Source

derp

master
Rich Brown 1 year ago
parent
commit
dfd64e836f
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      routes/createRouter.js

+ 2
- 2
routes/createRouter.js View File

@@ -15,7 +15,7 @@ const upload = multer({ storage });

const createRouter = express.Router();

const sanitizeFile = (file) => {
const sanitizedFile = (file) => {
const fileExts = ['png', 'jpg', 'jpeg', 'gif'];
const isAllowedExt = fileExts.includes(file.originalname.split('.')[1].toLowerCase());
const isAllowedMimeType = file.mimetype.startsWith('image/');
@@ -24,7 +24,7 @@ const sanitizeFile = (file) => {

createRouter.post('/form', upload.single('file'), (req, res) => {
const { file, body: { title, body, arrayOfTags } } = req;
if (!sanitizeFile()) {
if (!sanitizedFile(file)) {
res.status(403).json({ error: 'not an allowed filetype', url: null });
}
return req.app.locals.mp


Loading…
Cancel
Save