-
-
Save MaxWright/708c57895c447615c34dbb2086a34dc1 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