From f71dba4311dfbb2c11df6fa36302fea2d6f0d9e5 Mon Sep 17 00:00:00 2001 From: Steven Gill Date: Wed, 24 Jul 2013 14:37:20 -0700 Subject: [PATCH 1/5] updated namespace, name tag and readme --- README.md | 2 +- plugin.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 603e478..42a24d9 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ cordova-plugin-file-transfer ---------------------------- To install this plugin, follow the [Command-line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface). -If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html). +If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/plugin_ref_plugman.md.html). diff --git a/plugin.xml b/plugin.xml index 8d12037..b619adf 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,9 +1,9 @@ - - File Transfer + filetransfer From 95fa68041ef5e22d7e1647696f53eeef1379184d Mon Sep 17 00:00:00 2001 From: Viras- Date: Thu, 5 Sep 2013 07:00:38 +0200 Subject: [PATCH 2/5] [CB-4668] WP8 FileTransfer works with the standard JS implementation. Fixing error in parsing of HTTP params which causes sub-JSON objects to not work --- plugin.xml | 8 +-- src/wp/FileTransfer.cs | 4 +- www/wp/FileTransfer.js | 123 ----------------------------------------- 3 files changed, 3 insertions(+), 132 deletions(-) delete mode 100644 www/wp/FileTransfer.js diff --git a/plugin.xml b/plugin.xml index bb36fa9..9fce0ae 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,9 +1,8 @@ - + version="0.3.0"> File Transfer Cordova File Transfer Plugin Apache 2.0 @@ -84,11 +83,6 @@ - - - - - diff --git a/src/wp/FileTransfer.cs b/src/wp/FileTransfer.cs index a04e949..fb37c87 100644 --- a/src/wp/FileTransfer.cs +++ b/src/wp/FileTransfer.cs @@ -1,4 +1,4 @@ -/* +/* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -293,7 +293,7 @@ namespace WPCordovaClassLib.Cordova.Commands string[] strHeaders = temp.Split(','); for (int n = 0; n < strHeaders.Length; n++) { - string[] split = strHeaders[n].Split(':'); + string[] split = strHeaders[n].Split(":".ToCharArray(), 2); if (split.Length == 2) { split[0] = JSON.JsonHelper.Deserialize(split[0]); diff --git a/www/wp/FileTransfer.js b/www/wp/FileTransfer.js deleted file mode 100644 index b2f8686..0000000 --- a/www/wp/FileTransfer.js +++ /dev/null @@ -1,123 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * -*/ - -var exec = require('cordova/exec'), - FileTransferError = require('cordova/plugin/FileTransferError'); - -// Note that the only difference between this and the default implementation is the -// object literal passed to exec() in upload - jm - -/** - * FileTransfer uploads a file to a remote server. - * @constructor - */ -var FileTransfer = function() {}; - -/** -* Given an absolute file path, uploads a file on the device to a remote server -* using a multipart HTTP request. -* @param filePath {String} Full path of the file on the device -* @param server {String} URL of the server to receive the file -* @param successCallback (Function} Callback to be invoked when upload has completed -* @param errorCallback {Function} Callback to be invoked upon error -* @param options {FileUploadOptions} Optional parameters such as file name and mimetype -* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false -*/ - -FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) { - - // sanity parameter checking - if (!filePath || !server) throw new Error("FileTransfer.upload requires filePath and server URL parameters at the minimum."); - // check for options - var fileKey = null; - var fileName = null; - var mimeType = null; - var params = null; - var chunkedMode = true; - - if (options) { - fileKey = options.fileKey; - fileName = options.fileName; - mimeType = options.mimeType; - if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") { - chunkedMode = options.chunkedMode; - } - - // if options are specified, and NOT a string already, we will stringify it. - if(options.params && typeof options.params != typeof "") { - var arrParams = []; - for(var v in options.params) { - arrParams.push(v + "=" + options.params[v]); - } - params = encodeURI(arrParams.join("&")); - } - } - - var fail = function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status); - errorCallback(error); - }; - exec(successCallback, fail, 'FileTransfer', 'upload', [{"filePath":filePath, - "server":server, - "fileKey":fileKey, - "fileName":fileName, - "mimeType":mimeType, - "params":params, - "trustAllHosts":trustAllHosts, - "chunkedMode":chunkedMode}]); -}; - -/** - * Downloads a file form a given URL and saves it to the specified directory. - * @param source {String} URL of the server to receive the file - * @param target {String} Full path of the file on the device - * @param successCallback (Function} Callback to be invoked when upload has completed - * @param errorCallback {Function} Callback to be invoked upon error - */ - -FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) { - // sanity parameter checking - if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum."); - var win = function(result) { - var entry = null; - if (result.isDirectory) { - entry = new (require('cordova/plugin/DirectoryEntry'))(); - } - else if (result.isFile) { - entry = new (require('cordova/plugin/FileEntry'))(); - } - entry.isDirectory = result.isDirectory; - entry.isFile = result.isFile; - entry.name = result.name; - entry.fullPath = result.fullPath; - successCallback(entry); - }; - - var fail = function(e) { - var error = new FileTransferError(e.code, e.source, e.target, e.http_status); - errorCallback(error); - }; - - exec(win, errorCallback, 'FileTransfer', 'download', [source, target]); -}; - - -module.exports = FileTransfer; From 2e868f197f06db4320b4b383bd2cd4b76fcf51a2 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Thu, 5 Sep 2013 23:55:26 -0400 Subject: [PATCH 3/5] Add empty CHANGELOG.md --- CHANGELOG.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..6195996 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ + +# Release Notes + + From 66ad62f92dd4d87c1fe73f8f27fe42b3f1229c8d Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Fri, 6 Sep 2013 00:58:22 -0400 Subject: [PATCH 4/5] [CB-4752] Incremented plugin version on dev branch. --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 9fce0ae..5a686f6 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="0.3.1-dev"> File Transfer Cordova File Transfer Plugin Apache 2.0 From 5a0e96113d4e1d07dc0eba734893f3db2ff6f248 Mon Sep 17 00:00:00 2001 From: Viras- Date: Fri, 6 Sep 2013 07:17:35 +0200 Subject: [PATCH 5/5] [CB-4668] updating WP7 definition to use same code as WP8 --- plugin.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugin.xml b/plugin.xml index 9fce0ae..19e110f 100644 --- a/plugin.xml +++ b/plugin.xml @@ -67,11 +67,6 @@ - - - - -