Skip to content

Instantly share code, notes, and snippets.

View maxieds's full-sized avatar
🛸
I believe! Actively seeking lawyers (Alex) nobody else can afford post Area51.

Dr. Maxie Dion Schmidt maxieds

🛸
I believe! Actively seeking lawyers (Alex) nobody else can afford post Area51.
View GitHub Profile
@domharrington
domharrington / gist:884346cc04c30eeb1237
Created November 28, 2014 14:55
Download file via ajax. Copied from here http://stackoverflow.com/a/23797348
module.exports = downloadAjaxFile
function downloadAjaxFile (xhr) {
/* jshint maxcomplexity: 7 */
var filename = ''
, disposition = xhr.getResponseHeader('Content-Disposition')
if (disposition && disposition.indexOf('attachment') !== -1) {
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/
, matches = filenameRegex.exec(disposition)