Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expressjs download filename utf-8

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...

like image 961
LostCode Avatar asked May 27 '14 17:05

LostCode


2 Answers

Try this:

res.set("Content-Disposition", "attachment;filename=" + encodeURI("테스트 한글.hwp"));
like image 30
Sangbum Woo Avatar answered Sep 30 '22 19:09

Sangbum Woo


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.

like image 82
Artur Czyżewski Avatar answered Sep 30 '22 20:09

Artur Czyżewski