Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
565 views
in Technique[技术] by (71.8m points)

egg+typescript上传中文文件名的文件时会出现中文乱码

const { ctx } = this;
const stream = await ctx.getFileStream();
console.log(stream);

如果是文件名是英文的话,一切正常
但如果文件名是中文的话,打印出来的 stream.filename 会出现乱码

案例

image.png
image.png
stream中的 filename 属性就会打印出乱码,现在是有这个项目需求需要获取文件的文件名并且支持上传中文文件名的文件,想问问有没有大佬能解决这个问题


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

postman 会额外增加一个filename,你试试用网页版的postman。

不行的话,filename先编码,egg获取后解码


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...