Skip to content

Instantly share code, notes, and snippets.

View wemersonjanuario's full-sized avatar

Wemerson Januario wemersonjanuario

View GitHub Profile
@wemersonjanuario
wemersonjanuario / saveas.js
Created December 23, 2017 03:18 — forked from rreimi/saveas.js
Ajax blob save as.. file download
var url = 'http://www.pdf995.com/samples/pdf.pdf';
var fileName = 'pdf.pdf';
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onprogress = function(pe) {
console.log('progress');
if (pe.lengthComputable) {
console.log((pe.loaded / pe.total) * 100);
@wemersonjanuario
wemersonjanuario / blob.js
Created December 23, 2017 03:18 — forked from jgab-net/blob.js
Download file with xhr2 [blob url & html5 file api]
var url = 'http://backend.siplik.co/public/word-to-pdf.pdf';
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'blob';
xhr.onprogress = function(pe) {
console.log('progress');
if (pe.lengthComputable) {
console.log((pe.loaded / pe.total) * 100);