Example now uses built-in btoa instead of custom base64 encoding

untar^2
Jameson Little 2011-07-31 20:09:56 -06:00
parent 84f5e0b4df
commit 4763e4c2c3
1 changed files with 10 additions and 1 deletions

View File

@ -19,11 +19,20 @@
url,
base64;
function uint8ToString(buf) {
var i, length, out = '';
for (i = 0, length = buf.length; i < length; i += 1) {
out += String.fromCharCode(buf[i]);
}
return out;
}
out = tape.append('output.txt', 'This is test1!');
out = tape.append('dir/out.txt', 'This is test2! I changed up the directory');
out = tape.append('arr.txt', utils.stringToUint8('This is a Uint8Array!'));
base64 = utils.uint8ToBase64(out);
base64 = btoa(uint8ToString(out));
url = "data:application/tar;base64," + base64;
window.open(url);