Browse Source

tweak

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

+ 4
- 2
routes/createRouter.js View File

@@ -9,9 +9,11 @@ const storage = multer.diskStorage({
cb(null, 'uploads/');
},
filename(req, file, cb) {
const { originalname: { og } } = file;
const { originalname } = file;
const fiver = Math.random().toString(36).substr(2, 5);
cb(null, `${og}-${fiver}${path.extname(og)}`);
const newFilename = `${originalname}-${fiver}${path.extname(originalname)}`;
console.log(newFilename);
cb(null, newFilename);
},
});
const upload = multer({ storage });


Loading…
Cancel
Save