opt(core): optimization file download with encodeURIComponent and UTF-8 on filename

This commit is contained in:
OldHawk
2017-12-27 15:38:11 +08:00
parent cf311b3f7a
commit 845c40ea93
5 changed files with 45 additions and 37 deletions

View File

@@ -1025,7 +1025,7 @@ exports.attachDownload = function (req, res) {
try {
//res.set('Content-Type', 'application/x-bittorrent');
res.set('Content-Disposition', 'attachment; filename=' + encodeURI(filename));
res.set('Content-Disposition', 'attachment; filename*=UTF-8\'\'' + encodeURIComponent(filename));
res.set('Content-Length', stat.size);
fs.createReadStream(filePath).pipe(res);