cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/6] git commit: Merge branch 'fix-win8' of https://github.com/Touchit/cordova-plugin-file-transfer into dev
Date Mon, 28 Oct 2013 22:12:16 GMT
Updated Branches:
  refs/heads/dev d7db66c81 -> 60f96e078


Merge branch 'fix-win8' of https://github.com/Touchit/cordova-plugin-file-transfer into dev


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/32e980db
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/32e980db
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/32e980db

Branch: refs/heads/dev
Commit: 32e980dbde11f0f20d9dfe01b13e70be29386f14
Parents: 2be905f
Author: purplecabbage <purplecabbage@gmail.com>
Authored: Mon Sep 30 14:03:05 2013 -0700
Committer: purplecabbage <purplecabbage@gmail.com>
Committed: Thu Oct 3 10:46:27 2013 -0700

----------------------------------------------------------------------
 www/FileTransfer.js               |  2 +-
 www/windows8/FileTransferProxy.js | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/32e980db/www/FileTransfer.js
----------------------------------------------------------------------
diff --git a/www/FileTransfer.js b/www/FileTransfer.js
index e8e89be..66a1c4b 100644
--- a/www/FileTransfer.js
+++ b/www/FileTransfer.js
@@ -42,7 +42,7 @@ function getBasicAuthHeader(urlString) {
 
         var credentials = null;
         var protocol = url.protocol + "//";
-        var origin = protocol + url.host;
+        var origin = protocol + url.host.replace(":" + url.port, ""); // Windows 8 (IE10)
append :80 or :443 to url.host
 
         // check whether there are the username:password credentials in the url
         if (url.href.indexOf(origin) !== 0) { // credentials found

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/32e980db/www/windows8/FileTransferProxy.js
----------------------------------------------------------------------
diff --git a/www/windows8/FileTransferProxy.js b/www/windows8/FileTransferProxy.js
index e3a28d6..4ca88fc 100644
--- a/www/windows8/FileTransferProxy.js
+++ b/www/windows8/FileTransferProxy.js
@@ -29,6 +29,7 @@ module.exports = {
     upload:function(successCallback, error, options) {
         var filePath = options[0];
         var server = options[1];
+        var headers = options[8] || {};
 
 
         var win = function (fileUploadResult) {
@@ -49,7 +50,7 @@ module.exports = {
                 var blob = MSApp.createBlobFromRandomAccessStream(storageFile.contentType,
stream);
                 var formData = new FormData();
                 formData.append("source\";filename=\"" + storageFile.name + "\"", blob);
-                WinJS.xhr({ type: "POST", url: server, data: formData }).then(function (response)
{
+                WinJS.xhr({ type: "POST", url: server, data: formData, headers: headers }).then(function
(response) {
                     var code = response.status;
                     storageFile.getBasicPropertiesAsync().done(function (basicProperties)
{
 
@@ -73,6 +74,7 @@ module.exports = {
     download:function(win, error, options) {
         var source = options[0];
         var target = options[1];
+        var headers = options[4] || {};
 
 
         if (target === null || typeof target === undefined) {
@@ -96,6 +98,13 @@ module.exports = {
             storageFolder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.generateUniqueName).then(function
(storageFile) {
                 var uri = Windows.Foundation.Uri(source);
                 var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader();
+
+                if (headers) {
+                    for (var header in headers) {
+                        downloader.setRequestHeader(header, headers[header]);
+                    }
+                }
+
                 download = downloader.createDownload(uri, storageFile);
                 download.startAsync().then(function () {
                     win(new FileEntry(storageFile.name, storageFile.path));


Mime
View raw message