mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
fix(upload): resolve Chinese filename encoding issue
This commit is contained in:
parent
33110193fe
commit
f778b2f5d6
@ -21,6 +21,7 @@
|
|||||||
"antd": "5.x",
|
"antd": "5.x",
|
||||||
"cos-nodejs-sdk-v5": "^2.11.14",
|
"cos-nodejs-sdk-v5": "^2.11.14",
|
||||||
"koa-static": "^5.0.0",
|
"koa-static": "^5.0.0",
|
||||||
|
"iconv-lite": "^0.6.3",
|
||||||
"mime-match": "^1.0.2",
|
"mime-match": "^1.0.2",
|
||||||
"mkdirp": "~0.5.4",
|
"mkdirp": "~0.5.4",
|
||||||
"multer": "^1.4.2",
|
"multer": "^1.4.2",
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { uid } from '@nocobase/utils';
|
import { uid } from '@nocobase/utils';
|
||||||
|
import iconv from 'iconv-lite';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
export function getFilename(req, file, cb) {
|
export function getFilename(req, file, cb) {
|
||||||
const baseName = path.basename(file.originalname, path.extname(file.originalname));
|
const originalname = iconv.decode(Buffer.from(file.originalname, 'binary'), 'utf8');
|
||||||
cb(null, `${baseName}-${uid(6)}${path.extname(file.originalname)}`);
|
const baseName = path.basename(originalname, path.extname(originalname));
|
||||||
|
cb(null, `${baseName}-${uid(6)}${path.extname(originalname)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const cloudFilenameGetter = (storage) => (req, file, cb) => {
|
export const cloudFilenameGetter = (storage) => (req, file, cb) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user