Last active
May 10, 2016 06:34
-
-
Save simongong/5c2dca1e3935751443e61688209bc9f2 to your computer and use it in GitHub Desktop.
JavsScript: get disposition header for response
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(userAgent, fileName) { | |
var suffix = '.zip'; | |
if(userAgent.indexOf('msie') >= 0 || userAgent.indexOf('chrome') >= 0) { | |
return 'attachment; filename=' + encodeURIComponent(fileName) + suffix; | |
} else if(userAgent.indexOf('firefox') >= 0) { | |
return 'attachment; filename*="utf8\'\'' + encodeURIComponent(fileName)+'"' + suffix; | |
} else { | |
return 'attachment; filename=' + new Buffer(fileName).toString('binary') + suffix; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment