Commit 299a0345 authored by Romain Courteaud's avatar Romain Courteaud

IndexedDB: return expected content type in getAttachment

parent dafc0c70
...@@ -283,6 +283,7 @@ ...@@ -283,6 +283,7 @@
IndexedDBStorage.prototype.getAttachment = function (id, name, options) { IndexedDBStorage.prototype.getAttachment = function (id, name, options) {
var transaction, var transaction,
type,
start, start,
end; end;
if (options === undefined) { if (options === undefined) {
...@@ -303,6 +304,7 @@ ...@@ -303,6 +304,7 @@
start_index, start_index,
end_index; end_index;
type = attachment.info.content_type;
start = options.start || 0; start = options.start || 0;
end = options.end || total_length; end = options.end || total_length;
if (end > total_length) { if (end > total_length) {
...@@ -340,8 +342,11 @@ ...@@ -340,8 +342,11 @@
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
array_buffer_list.push(result_list[i].blob); array_buffer_list.push(result_list[i].blob);
} }
if ((options.start === undefined) && (options.end === undefined)) {
return new Blob(array_buffer_list, {type: type});
}
blob = new Blob(array_buffer_list, {type: "application/octet-stream"}); blob = new Blob(array_buffer_list, {type: "application/octet-stream"});
return blob.slice(start, end); return blob.slice(start, end, "application/octet-stream");
}); });
}; };
......
...@@ -1112,7 +1112,7 @@ ...@@ -1112,7 +1112,7 @@
var context = this, var context = this,
attachment = "attachment"; attachment = "attachment";
stop(); stop();
expect(2); expect(3);
deleteIndexedDB(context.jio) deleteIndexedDB(context.jio)
.then(function () { .then(function () {
...@@ -1126,6 +1126,7 @@ ...@@ -1126,6 +1126,7 @@
}) })
.then(function (result) { .then(function (result) {
ok(result instanceof Blob, "Data is Blob"); ok(result instanceof Blob, "Data is Blob");
equal(result.type, "text/plain;charset=utf-8");
return jIO.util.readBlobAsText(result); return jIO.util.readBlobAsText(result);
}) })
.then(function (result) { .then(function (result) {
...@@ -1144,7 +1145,7 @@ ...@@ -1144,7 +1145,7 @@
var context = this, var context = this,
attachment = "attachment"; attachment = "attachment";
stop(); stop();
expect(2); expect(3);
deleteIndexedDB(context.jio) deleteIndexedDB(context.jio)
.then(function () { .then(function () {
...@@ -1159,6 +1160,7 @@ ...@@ -1159,6 +1160,7 @@
}) })
.then(function (result) { .then(function (result) {
ok(result instanceof Blob, "Data is Blob"); ok(result instanceof Blob, "Data is Blob");
equal(result.type, "application/octet-stream");
return jIO.util.readBlobAsText(result); return jIO.util.readBlobAsText(result);
}) })
.then(function (result) { .then(function (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