Skip to content

Instantly share code, notes, and snippets.

test

Keybase proof

I hereby claim:

  • I am forestmaxime on github.
  • I am forestmaxime (https://keybase.io/forestmaxime) on keybase.
  • I have a public key ASAYUfKyDUYPK2DU9esZDYtGAoDDU7sbUu65C8d778oTyAo

To claim this, I am signing this object:

@forestmaxime
forestmaxime / DownloadBase64EncodedStringToFile.js
Created June 25, 2015 16:59
Download a base 64 encoded string to a file using javascript.
var filename = "";
var disposition = xhr.getResponseHeader('Content-Disposition');
if (disposition && disposition.indexOf('attachment') !== -1) {
var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
var matches = filenameRegex.exec(disposition);
if (matches != null && matches[1]) filename = matches[1].replace(/['"]/g, "");
}
var contentType = xhr.getResponseHeader("Content-Type");
var blob = this.b64ToBlob(response, contentType);