Reputation: 533
express response.download filename is not support utf-8.
I wanna download file, file naming utf-8 (not english)
I already try Content-Disposition
set to header
like this...
res.set "Content-Disposition", "attachment;filename=테스트 한글.hwp"
but not working...
Upvotes: 6
Views: 6682
Reputation: 1405
https://www.npmjs.com/package/content-disposition
res.set("Content-Disposition", contentDisposition("테스트 한글.hwp")
const {
parameters: { filename }
} = contentDisposition.parse(resp.headers['content-disposition'])
Upvotes: 0
Reputation: 3087
Here is a popular library for UTF8 encoding/decoding https://www.npmjs.com/package/utf8
res.setHeader('Content-disposition', 'attachment; filename='+utf8.encode(object.pdfFileName));
Upvotes: 0
Reputation: 21
Try this:
res.set("Content-Disposition", "attachment;filename=" + encodeURI("테스트 한글.hwp"));
Upvotes: 2
Reputation: 833
var newFileName = encodeURIComponent("테스트 한글.hwp");
res.setHeader('Content-Disposition', 'attachment;filename*=UTF-8\'\''+newFileName);
This should do the trick. It helps me with polish diacritics. Note the =UTF-8\'\' part.
Upvotes: 14