From fd8a870925fe5de932b9069205e6cf9869894c73 Mon Sep 17 00:00:00 2001 From: Tristan Cavelier <tristan.cavelier@tiolive.com> Date: Thu, 19 Sep 2013 13:55:35 +0200 Subject: [PATCH] davstorage getAttachment doesn't return content type - fixed --- src/jio.storage/davstorage.js | 5 +++-- test/jio.storage/davstorage.livetests.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/jio.storage/davstorage.js b/src/jio.storage/davstorage.js index 4dcae47..42cbaab 100644 --- a/src/jio.storage/davstorage.js +++ b/src/jio.storage/davstorage.js @@ -5,7 +5,7 @@ */ /*jslint indent: 2, maxlen: 80, nomen: true, regexp: true, unparam: true */ -/*global define, window, jIO, promy, btoa, DOMParser */ +/*global define, window, jIO, promy, btoa, DOMParser, Blob */ // JIO Dav Storage Description : // { @@ -609,6 +609,7 @@ }}; } delete o["Not Found"]; + o.type = attachment.content_type || "application/octet-stream"; o.notify_message = "Retrieving attachment"; o.percentage = [30, 100]; o.digest = attachment.digest; @@ -616,7 +617,7 @@ }.bind(this), success: function (e) { command.success(e.target.status, { - "data": e.target.response, + "data": new Blob([e.target.response], {"type": o.type}), "digest": o.digest }); }, diff --git a/test/jio.storage/davstorage.livetests.js b/test/jio.storage/davstorage.livetests.js index e93c89d..c267c5d 100644 --- a/test/jio.storage/davstorage.livetests.js +++ b/test/jio.storage/davstorage.livetests.js @@ -45,7 +45,7 @@ * X-Requested-With, X-HTTP-Method-Override, Accept, Authorization, * Depth" */ - test("Scenario", 29, function () { + test("Scenario", 31, function () { ok(!(/^file:/.test(location.href)), "Should not work on file protocol: " + location.href); @@ -322,6 +322,7 @@ "statusText": "Ok" }, "Get first attachment"); return jIO.util.readBlobAsText(blob).then(function (e) { + deepEqual(blob.type, "text/plain", "Check blob type"); deepEqual(e.target.result, "aab", "Check blob text content"); }, function (err) { deepEqual(err, "no error", "Check blob text content"); @@ -347,6 +348,7 @@ "statusText": "Ok" }, "Get first attachment"); return jIO.util.readBlobAsText(blob).then(function (e) { + deepEqual(blob.type, "text/plain", "Check blob type"); deepEqual(e.target.result, "aba", "Check blob text content"); }, function (err) { deepEqual(err, "no error", "Check blob text content"); -- 2.30.9