Skip to content

Commit

Permalink
🐛 replace space for filename
Browse files Browse the repository at this point in the history
  • Loading branch information
songquanpeng committed Jan 28, 2023
1 parent 77b0251 commit 356c1b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion middlewares/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ exports.upload = multer({
callback(null, uploadPath);
},
filename: async function(req, file, callback) {
if (await fileExists(path.join(uploadPath, file.originalname))) {
file.originalname = file.originalname.replaceAll(" ", "_");
if (await fileExists(path.join(uploadPath, path.basename(file.originalname)))) {
let parts = file.originalname.split('.');
let extension = "";
if (parts.length > 1) {
Expand Down

0 comments on commit 356c1b9

Please sign in to comment.