Created
February 23, 2012 16:24
-
-
Save robnyman/1893530 to your computer and use it in GitHub Desktop.
xhr-BlobBuilder
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
// Create XHR | |
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 | |
xhr.send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment