Skip to content

Commit

Permalink
Fix UTF-8 file name encoding for uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Aug 14, 2022
1 parent 6dee1f3 commit aead7f3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ const setupRoute = require('./setup');
const loginRoute = require('./login');
const indexRoute = require('./index');
const utils = require('../services/utils');
const multer = require('multer')();
const multer = require('multer')({
fileFilter: (req, file, cb) => {
// UTF-8 file names are not well decoded by multer/busboy, so we handle the conversion on our side.
// See https://github.com/mscdex/busboy/issues/247.
file.originalname = Buffer.from(file.originalname, "latin1").toString("utf-8");
cb(null, true);
}
});

// API routes
const treeApiRoute = require('./api/tree');
Expand Down

0 comments on commit aead7f3

Please sign in to comment.