Skip to content

Instantly share code, notes, and snippets.

@MaxWright
MaxWright / xhr-BlobBuilder.js
Created August 23, 2018 21:37 — forked from robnyman/xhr-BlobBuilder.js
xhr-BlobBuilder
// 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) {
@MaxWright
MaxWright / retrieve-indexeddb-file-create-object-url.js
Created August 23, 2018 21:37 — forked from robnyman/retrieve-indexeddb-file-create-object-url.js
Retrieve stored file from IndexedDB and create an ObjectURL
// Retrieve the file that was just stored
transaction.objectStore("elephants").get("image").onsuccess = function (event) {
var imgFile = event.target.result;
console.log("Got elephant!" + imgFile);
// Get window.URL object
var URL = window.URL || window.webkitURL;
// Create and revoke ObjectURL
var imgURL = URL.createObjectURL(imgFile);