From f8d68b880f46144cb08c3254fb17a6eadcb0be90 Mon Sep 17 00:00:00 2001 From: Ilya Lebedev Date: Tue, 12 Feb 2013 16:49:40 +0400 Subject: [PATCH] Added Content-Type header --- lib/FileAPI.Form.js | 10 ++++++---- lib/FileAPI.XHR.js | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/FileAPI.Form.js b/lib/FileAPI.Form.js index 6489a6f3..e29b043f 100644 --- a/lib/FileAPI.Form.js +++ b/lib/FileAPI.Form.js @@ -92,16 +92,18 @@ queue.inc(); file.blob.toBlob(function (blob){ data.name = file.name; - data.file = blob; - data.size = blob.length; + data.file = blob; + data.size = blob.length; + data.type = file.type; queue.next(); }, 'image/png'); } else if( file.file ){ //file data.name = file.blob.name; - data.file = file.blob; - data.size = file.blob.size; + data.file = file.blob; + data.size = file.blob.size; + data.type = file.type; } else { // additional data diff --git a/lib/FileAPI.XHR.js b/lib/FileAPI.XHR.js index 0a05ddf2..5cb93d2f 100644 --- a/lib/FileAPI.XHR.js +++ b/lib/FileAPI.XHR.js @@ -204,6 +204,7 @@ xhr.setRequestHeader("Content-Range", "bytes " + data.start + "-" + data.end + "/" + data.size); xhr.setRequestHeader("Content-Disposition", 'attachment; filename=' + encodeURIComponent(data.name)); + xhr.setRequestHeader("Content-Type", data.type || "application/octet-stream"); slice = data.file[slice](data.start, data.end + 1);