Created
October 2, 2014 23:14
-
-
Save meandavejustice/d21448317dc6b8a822cd to your computer and use it in GitHub Desktop.
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
function _base64toArrayBuffer(base64) { | |
var binary_string = window.atob(base64); | |
var len = binary_string.length; | |
var bytes = new Uint8Array( len ); | |
for (var i = 0; i < len; i++) { | |
var ascii = binary_string.charCodeAt(i); | |
bytes[i] = ascii; | |
} | |
return bytes.buffer; | |
} | |
function genURL(key, cb) { | |
orm.get(key, function(err, data) { | |
if (err) cb(err); | |
var arrBuffer = _base64toArrayBuffer(data.base64); | |
var blob = new Blob([arrBuffer], {type: data.type}); | |
var url = URL.createObjectURL(blob); | |
cb(null, url); | |
}) | |
} | |
module.exports = genURL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment