cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/4] git commit: CB-7529 Adds support for 'ms-appdata' URIs for windows
Date Wed, 17 Sep 2014 21:46:11 GMT
Repository: cordova-plugin-file-transfer
Updated Branches:
  refs/heads/master edcdfebf0 -> e30057678


CB-7529 Adds support for 'ms-appdata' URIs for windows


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/49c57d27
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/49c57d27
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/49c57d27

Branch: refs/heads/master
Commit: 49c57d27b38df9e11e53c4bc11495d9f6a13852e
Parents: d1642de
Author: Vladimir Kotikov <v-vlkoti@microsoft.com>
Authored: Fri Sep 12 10:10:33 2014 +0400
Committer: Vladimir Kotikov <v-vlkoti@microsoft.com>
Committed: Fri Sep 12 10:10:33 2014 +0400

----------------------------------------------------------------------
 src/windows/FileTransferProxy.js | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/49c57d27/src/windows/FileTransferProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/FileTransferProxy.js b/src/windows/FileTransferProxy.js
index ba474a4..9133801 100644
--- a/src/windows/FileTransferProxy.js
+++ b/src/windows/FileTransferProxy.js
@@ -62,7 +62,7 @@ exec(win, fail, 'FileTransfer', 'upload',
 [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers,
this._id, httpMethod]);
 */
     upload:function(successCallback, errorCallback, options) {
-        var filePath = cordovaPathToNative(options[0]);
+        var filePath = options[0];
         var server = options[1];
         var fileKey = options[2] || 'source';
         var fileName = options[3];
@@ -80,7 +80,14 @@ exec(win, fail, 'FileTransfer', 'upload',
 
         if (String(filePath).substr(0, 8) == "file:///") {
             filePath = Windows.Storage.ApplicationData.current.localFolder.path + String(filePath).substr(8).split("/").join("\\");
+        } else if (String(filePath).indexOf('ms-appdata:///') === 0) {
+            // Handle 'ms-appdata' scheme
+            filePath = filePath.toString()
+                .replace('ms-appdata:///local', Windows.Storage.ApplicationData.current.localFolder.path)
+                .replace('ms-appdata:///temp', Windows.Storage.ApplicationData.current.temporaryFolder.path);
         }
+        // normalize path separators
+        filePath = cordovaPathToNative(filePath);
 
         // Create internal download operation object
         fileTransferOps[uploadId] = new FileTransferOperation(FileTransferOperation.PENDING,
null);
@@ -155,14 +162,20 @@ exec(win, fail, 'FileTransfer', 'upload',
         var downloadId = options[3];
         var headers = options[4] || {};
 
-
         if (target === null || typeof target === undefined) {
             errorCallback && errorCallback(FileTransferError.FILE_NOT_FOUND_ERR);
             return;
         }
         if (String(target).substr(0, 8) == "file:///") {
             target = Windows.Storage.ApplicationData.current.localFolder.path + String(target).substr(8).split("/").join("\\");
+        } else if (String(target).indexOf('ms-appdata:///') === 0) {
+            // Handle 'ms-appdata' scheme
+            target = target.toString()
+                .replace('ms-appdata:///local', Windows.Storage.ApplicationData.current.localFolder.path)
+                .replace('ms-appdata:///temp', Windows.Storage.ApplicationData.current.temporaryFolder.path);
         }
+        target = cordovaPathToNative(target);
+
         var path = target.substr(0, String(target).lastIndexOf("\\"));
         var fileName = target.substr(String(target).lastIndexOf("\\") + 1);
         if (path === null || fileName === null) {


Mime
View raw message