diff --git a/README.md b/README.md index 06f22b8..f6dc548 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,9 @@ description: Upload and download files. # under the License. --> -|Android 4.4|Android 5.1|iOS 9.3|iOS 10.0|Windows 10 Store|Travis CI| -|:-:|:-:|:-:|:-:|:-:|:-:| -|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-file-transfer)| +|Android 4.4|Android 5.1|Android 6.0|iOS 9.3|iOS 10.0|Windows 10 Store|Travis CI| +|:-:|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-4.4,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-5.1,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android-6.0,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-9.3,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios-10.0,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-file-transfer)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-file-transfer/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-file-transfer.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-file-transfer)| # cordova-plugin-file-transfer diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 989206b..b2ccebb 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -20,6 +20,10 @@ --> # Release Notes +### 1.6.3 (Apr 27, 2017) +* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder +* [CB-10696](https://issues.apache.org/jira/browse/CB-10696) **iOS**: Encode target path with spaces + ### 1.6.2 (Feb 28, 2017) * [CB-12353](https://issues.apache.org/jira/browse/CB-12353) Corrected merges usage in `plugin.xml` * [CB-12369](https://issues.apache.org/jira/browse/CB-12369) Add plugin typings from `DefinitelyTyped` diff --git a/package.json b/package.json index 39a04b5..1f331c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-file-transfer", - "version": "1.6.2", + "version": "1.6.3", "description": "Cordova File Transfer Plugin", "types": "./types/index.d.ts", "cordova": { diff --git a/plugin.xml b/plugin.xml index 1b16101..4566230 100644 --- a/plugin.xml +++ b/plugin.xml @@ -21,7 +21,7 @@ + version="1.6.3"> File Transfer Cordova File Transfer Plugin Apache 2.0 diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m index 9b01049..ab59012 100644 --- a/src/ios/CDVFileTransfer.m +++ b/src/ios/CDVFileTransfer.m @@ -440,6 +440,13 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) targetURL = [[self.commandDelegate getCommandInstance:@"File"] fileSystemURLforLocalPath:target].url; } else { targetURL = [NSURL URLWithString:target]; + + if (targetURL == nil) { + NSString* targetUrlTextEscaped = [target stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]; + if (targetUrlTextEscaped) { + targetURL = [NSURL URLWithString:targetUrlTextEscaped]; + } + } } NSURL* sourceURL = [NSURL URLWithString:source]; @@ -447,6 +454,9 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) if (!sourceURL) { errorCode = INVALID_URL_ERR; NSLog(@"File Transfer Error: Invalid server URL %@", source); + } else if (!targetURL) { + errorCode = INVALID_URL_ERR; + NSLog(@"File Tranfer Error: Invalid target URL %@", target); } else if (![targetURL isFileURL]) { CDVFilesystemURL *fsURL = [CDVFilesystemURL fileSystemURLWithString:target]; if (!fsURL) { diff --git a/tests/package.json b/tests/package.json new file mode 100644 index 0000000..a02fa86 --- /dev/null +++ b/tests/package.json @@ -0,0 +1,14 @@ +{ + "name": "cordova-plugin-file-transfer-tests", + "version": "1.6.3-dev", + "description": "", + "cordova": { + "id": "cordova-plugin-file-transfer-tests", + "platforms": [] + }, + "keywords": [ + "ecosystem:cordova" + ], + "author": "", + "license": "Apache 2.0" +} diff --git a/tests/plugin.xml b/tests/plugin.xml index 6f55534..6fb7fb9 100644 --- a/tests/plugin.xml +++ b/tests/plugin.xml @@ -21,7 +21,7 @@ + version="1.6.3"> Cordova File Transfer Plugin Tests Apache 2.0 diff --git a/tests/tests.js b/tests/tests.js index 98acb4c..04a3e72 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -398,6 +398,47 @@ exports.defineAutoTests = function () { specContext.transfer.download(fileURL, specContext.localFilePath, downloadWin, downloadFail); }, DOWNLOAD_TIMEOUT * 10); // to give Heroku server some time to wake up + it("filetransfer.spec.4.1 should download a file using target name with space", function (done) { + + var fileURL = SERVER + "/robots.txt"; + this.fileName = "test file.txt"; + this.localFilePath = this.root.toURL() + this.fileName; + + var specContext = this; + + var fileWin = function (blob) { + + if (specContext.transfer.onprogress.calls.any()) { + var lastProgressEvent = specContext.transfer.onprogress.calls.mostRecent().args[0]; + expect(lastProgressEvent.loaded).not.toBeGreaterThan(blob.size); + } else { + console.log("no progress events were emitted"); + } + + done(); + }; + + var fileSystemFail = function() { + unexpectedCallbacks.fileSystemFail(); + done(); + }; + + var downloadFail = function() { + unexpectedCallbacks.httpFail(); + done(); + }; + + var downloadWin = function (entry) { + + verifyDownload(entry, specContext); + + // verify the FileEntry representing this file + entry.file(fileWin, fileSystemFail); + }; + + specContext.transfer.download(fileURL, specContext.localFilePath, downloadWin, downloadFail); + }, DOWNLOAD_TIMEOUT * 10); // to give Heroku server some time to wake up + it("filetransfer.spec.5 should download a file using http basic auth", function (done) { var fileURL = SERVER_WITH_CREDENTIALS + "/download_basic_auth"; var specContext = this;