Commit 902f54fe authored by Romain Courteaud's avatar Romain Courteaud

Store blob as text in localstorage.

parent 4a176103
...@@ -69,20 +69,12 @@ ...@@ -69,20 +69,12 @@
LocalStorage.prototype.getAttachment = function (param) { LocalStorage.prototype.getAttachment = function (param) {
restrictDocumentId(param._id); restrictDocumentId(param._id);
var binarystring = localStorage.getItem(param._attachment), var textstring = localStorage.getItem(param._attachment);
i,
uint8array;
if (binarystring === null) { if (textstring === null) {
throw new jIO.util.jIOError("Cannot find attachment", 404); throw new jIO.util.jIOError("Cannot find attachment", 404);
} }
return new Blob([textstring]);
uint8array = new Uint8Array(binarystring.length);
for (i = 0; i < binarystring.length; i += 1) {
uint8array[i] = binarystring.charCodeAt(i); // mask `& 0xFF` not necessary
}
return new Blob([uint8array.buffer]);
}; };
LocalStorage.prototype.putAttachment = function (param) { LocalStorage.prototype.putAttachment = function (param) {
...@@ -92,7 +84,7 @@ ...@@ -92,7 +84,7 @@
// download data // download data
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
return jIO.util.readBlobAsBinaryString(param._blob); return jIO.util.readBlobAsText(param._blob);
}) })
.push(function (e) { .push(function (e) {
localStorage.setItem(param._attachment, e.target.result); localStorage.setItem(param._attachment, e.target.result);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment