-
-
Save MaxWright/708c57895c447615c34dbb2086a34dc1 to your computer and use it in GitHub Desktop.
Revisions
-
robnyman revised this gist
Feb 28, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ // Create XHR var xhr = new XMLHttpRequest(), blob; -
robnyman revised this gist
Feb 28, 2012 . 1 changed file with 5 additions and 18 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,33 +1,20 @@ // Create XHR and BlobBuilder var xhr = new XMLHttpRequest(), blob; xhr.open("GET", "elephant.png", true); // Set the responseType to blob xhr.responseType = "blob"; xhr.addEventListener("load", function () { if (xhr.status === 200) { console.log("Image retrieved"); // File as response blob = xhr.response; // Put the received blob into IndexedDB putElephantInDb(blob); } }, false); // Send XHR -
robnyman created this gist
Feb 23, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ // Create XHR and BlobBuilder var xhr = new XMLHttpRequest(), blobBuilder = new (window.BlobBuilder || window.MozBlobBuilder || window.WebKitBlobBuilder || window.OBlobBuilder || window.msBlobBuilder), blob; xhr.open("GET", "elephant.png", true); // Set the responseType to arraybuffer. "blob" is an option too, rendering BlobBuilder unnecessary, but the support for "blob" is not widespread enough yet xhr.responseType = "arraybuffer"; xhr.addEventListener("load", function () { if (xhr.status === 200) { console.log("Image retrieved"); // File as response var response = xhr.response; if (blobBuilder) { // Append the response to the BlobBuilder blobBuilder.append(response); // Create a blob with the desired MIME type blob = blobBuilder.getBlob("image/png"); } else { blob = new Blob([response]); } if (blob) { // Put the received blob into IndexedDB putElephantInDb(blob); } } }, false); // Send XHR xhr.send();