Skip to content

Commit

Permalink
🐞 fix: Handle Garbled Chinese Characters in File Upload (#2261)
Browse files Browse the repository at this point in the history
Co-authored-by: 彭修照 <pengxiuzhao.uh@haier.com>
  • Loading branch information
pxz2016 and 彭修照 committed Apr 1, 2024
1 parent 4854b39 commit cc92597
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/server/routes/files/multer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const storage = multer.diskStorage({
},
filename: function (req, file, cb) {
req.file_id = crypto.randomUUID();
file.originalname = decodeURIComponent(file.originalname);
cb(null, `${file.originalname}`);
},
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/Files/useFileHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const useFileHandling = (params?: UseFileHandling) => {
startUploadTimer(extendedFile.file_id, extendedFile.file?.name || 'File');

const formData = new FormData();
formData.append('file', extendedFile.file as File);
formData.append('file', extendedFile.file as File, encodeURIComponent(extendedFile.file?.name || 'File'));
formData.append('file_id', extendedFile.file_id);
if (extendedFile.width) {
formData.append('width', extendedFile.width?.toString());
Expand Down

0 comments on commit cc92597

Please sign in to comment.