[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-14 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15056005#comment-15056005
 ] 

ASF subversion and git services commented on CB-9837:
-

Commit 182b0c5ebebd8c0d313c676de0f92b8a56a81cb1 in 
cordova-plugin-file-transfer's branch refs/heads/master from [~daserge]
[ 
https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-file-transfer.git;h=182b0c5
 ]

CB-9837 Add data URI support to file-transfer upload on iOS

Adds iOS and Windows implementation; mention in the docs
Adds corresponding tests
Increases spec.35 timeout for Windows Phone 8.1 case as it contains 2 download 
operations


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15056007#comment-15056007
 ] 

ASF GitHub Bot commented on CB-9837:


Github user asfgit closed the pull request at:

https://github.com/apache/cordova-plugin-file-transfer/pull/122


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-11 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15053685#comment-15053685
 ] 

ASF GitHub Bot commented on CB-9837:


Github user dblotsky commented on the pull request:


https://github.com/apache/cordova-plugin-file-transfer/pull/122#issuecomment-164065701
  
Ah, gotcha. Thanks for the explanation. If the tests pass, then it LGTM!


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-10 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15051566#comment-15051566
 ] 

ASF GitHub Bot commented on CB-9837:


Github user dblotsky commented on the pull request:


https://github.com/apache/cordova-plugin-file-transfer/pull/122#issuecomment-163736130
  
Thanks for documenting! What I mean is: is this a supported feature in the 
first place?


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-10 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15052252#comment-15052252
 ] 

ASF GitHub Bot commented on CB-9837:


Github user daserge commented on the pull request:


https://github.com/apache/cordova-plugin-file-transfer/pull/122#issuecomment-163852420
  
This fixes the manual test for camera plugin when [DATA_URI output is 
selected](https://github.com/apache/cordova-plugin-camera/blob/e1911a3c78592a23358caa0c4fc9429456942702/tests/tests.js#L121)
 and the file is [uploaded via 
file-transfer](https://github.com/apache/cordova-plugin-camera/blob/e1911a3c78592a23358caa0c4fc9429456942702/tests/tests.js#L170)
 so the scenario seems to be expected to work.


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15048945#comment-15048945
 ] 

ASF GitHub Bot commented on CB-9837:


Github user asfgit closed the pull request at:

https://github.com/apache/cordova-labs/pull/11


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15048913#comment-15048913
 ] 

ASF GitHub Bot commented on CB-9837:


GitHub user daserge opened a pull request:

https://github.com/apache/cordova-plugin-file-transfer/pull/122

CB-9837 Add data URI support to file-transfer upload on iOS

Adds iOS and Windows implementation
Adds corresponding tests

[Jira issue](https://issues.apache.org/jira/browse/CB-9837)

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/MSOpenTech/cordova-plugin-file-transfer 
CB-9837

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cordova-plugin-file-transfer/pull/122.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #122


commit f06eb15183943ceff65eacdf583ba2d787615ee2
Author: daserge 
Date:   2015-12-09T16:08:14Z

CB-9837 Add data URI support to file-transfer upload on iOS

Adds iOS and Windows implementation
Adds corresponding tests




> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-09 Thread ASF subversion and git services (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15048944#comment-15048944
 ] 

ASF subversion and git services commented on CB-9837:
-

Commit cf3dc1a462cd2245a216f5a54155ea4f93278122 in cordova-labs's branch 
refs/heads/cordova-filetransfer from [~daserge]
[ https://git-wip-us.apache.org/repos/asf?p=cordova-labs.git;h=cf3dc1a ]

CB-9837 Add data URI support to file-transfer upload on iOS

Increases direct upload limit to the test image size


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15049865#comment-15049865
 ] 

ASF GitHub Bot commented on CB-9837:


Github user dblotsky commented on a diff in the pull request:


https://github.com/apache/cordova-plugin-file-transfer/pull/122#discussion_r47181683
  
--- Diff: src/windows/FileTransferProxy.js ---
@@ -89,19 +179,141 @@ exec(win, fail, 'FileTransfer', 'upload',
 var isMultipart = typeof headers["Content-Type"] === 'undefined';
 
 if (!filePath || (typeof filePath !== 'string')) {
-errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR,null,server));
+errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, null, 
server));
 return;
 }
 
-if (filePath.substr(0, 8) === "file:///") {
-filePath = appData.localFolder.path + 
filePath.substr(8).split("/").join("\\");
-} else if (filePath.indexOf('ms-appdata:///') === 0) {
-// Handle 'ms-appdata' scheme
-filePath = filePath.replace('ms-appdata:///local', 
appData.localFolder.path)
-   .replace('ms-appdata:///temp', 
appData.temporaryFolder.path);
-} else if (filePath.indexOf('cdvfile://') === 0) {
-filePath = filePath.replace('cdvfile://localhost/persistent', 
appData.localFolder.path)
-   .replace('cdvfile://localhost/temporary', 
appData.temporaryFolder.path);
+if (filePath.indexOf("data:") === 0 && filePath.indexOf("base64") 
!== -1) {
+// First a DataWriter object is created, backed by an 
in-memory stream where 
+// the data will be stored.
+var writer = Windows.Storage.Streams.DataWriter(new 
Windows.Storage.Streams.InMemoryRandomAccessStream());
+writer.unicodeEncoding = 
Windows.Storage.Streams.UnicodeEncoding.utf8;
+writer.byteOrder = 
Windows.Storage.Streams.ByteOrder.littleEndian;
+
+var commaIndex = filePath.indexOf(",");
+if (commaIndex === -1) {
+errorCallback(new FTErr(FTErr.INVALID_URL_ERR, fileName, 
server, null, null, "No comma in data: URI"));
+return;
+}
+
+// Create internal download operation object
+fileTransferOps[uploadId] = new 
FileTransferOperation(FileTransferOperation.PENDING, null);
+
+var fileDataString = filePath.substr(commaIndex + 1);
+
+function stringToByteArray(str) {
+var byteCharacters = atob(str);
+var byteNumbers = new Array(byteCharacters.length);
+for (var i = 0; i < byteCharacters.length; i++) {
+byteNumbers[i] = byteCharacters.charCodeAt(i);
+}
+return new Uint8Array(byteNumbers);
+};
+
+// setting request headers for uploader
+var uploader = new 
Windows.Networking.BackgroundTransfer.BackgroundUploader();
+uploader.method = httpMethod;
+for (var header in headers) {
+if (headers.hasOwnProperty(header)) {
+uploader.setRequestHeader(header, headers[header]);
+}
+}
+
+if (isMultipart) {
+// adding params supplied to request payload
+var multipartParams = '';
+for (var key in params) {
+if (params.hasOwnProperty(key)) {
+multipartParams += LINE_START + BOUNDARY + 
LINE_END;
+multipartParams += "Content-Disposition: 
form-data; name=\"" + key + "\"";
--- End diff --

Is there a library that creates HTTP requests with forms?


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source 

[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15049870#comment-15049870
 ] 

ASF GitHub Bot commented on CB-9837:


Github user dblotsky commented on the pull request:


https://github.com/apache/cordova-plugin-file-transfer/pull/122#issuecomment-163464535
  
Are base64-encoded files documented as supported by the file transfer API?


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15050226#comment-15050226
 ] 

ASF GitHub Bot commented on CB-9837:


Github user daserge commented on the pull request:


https://github.com/apache/cordova-plugin-file-transfer/pull/122#issuecomment-163520007
  
Updated the docs, thanks.


> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org



[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15050211#comment-15050211
 ] 

ASF GitHub Bot commented on CB-9837:


Github user daserge commented on a diff in the pull request:


https://github.com/apache/cordova-plugin-file-transfer/pull/122#discussion_r47194431
  
--- Diff: src/windows/FileTransferProxy.js ---
@@ -89,19 +179,141 @@ exec(win, fail, 'FileTransfer', 'upload',
 var isMultipart = typeof headers["Content-Type"] === 'undefined';
 
 if (!filePath || (typeof filePath !== 'string')) {
-errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR,null,server));
+errorCallback(new FTErr(FTErr.FILE_NOT_FOUND_ERR, null, 
server));
 return;
 }
 
-if (filePath.substr(0, 8) === "file:///") {
-filePath = appData.localFolder.path + 
filePath.substr(8).split("/").join("\\");
-} else if (filePath.indexOf('ms-appdata:///') === 0) {
-// Handle 'ms-appdata' scheme
-filePath = filePath.replace('ms-appdata:///local', 
appData.localFolder.path)
-   .replace('ms-appdata:///temp', 
appData.temporaryFolder.path);
-} else if (filePath.indexOf('cdvfile://') === 0) {
-filePath = filePath.replace('cdvfile://localhost/persistent', 
appData.localFolder.path)
-   .replace('cdvfile://localhost/temporary', 
appData.temporaryFolder.path);
+if (filePath.indexOf("data:") === 0 && filePath.indexOf("base64") 
!== -1) {
+// First a DataWriter object is created, backed by an 
in-memory stream where 
+// the data will be stored.
+var writer = Windows.Storage.Streams.DataWriter(new 
Windows.Storage.Streams.InMemoryRandomAccessStream());
+writer.unicodeEncoding = 
Windows.Storage.Streams.UnicodeEncoding.utf8;
+writer.byteOrder = 
Windows.Storage.Streams.ByteOrder.littleEndian;
+
+var commaIndex = filePath.indexOf(",");
+if (commaIndex === -1) {
+errorCallback(new FTErr(FTErr.INVALID_URL_ERR, fileName, 
server, null, null, "No comma in data: URI"));
+return;
+}
+
+// Create internal download operation object
+fileTransferOps[uploadId] = new 
FileTransferOperation(FileTransferOperation.PENDING, null);
+
+var fileDataString = filePath.substr(commaIndex + 1);
+
+function stringToByteArray(str) {
+var byteCharacters = atob(str);
+var byteNumbers = new Array(byteCharacters.length);
+for (var i = 0; i < byteCharacters.length; i++) {
+byteNumbers[i] = byteCharacters.charCodeAt(i);
+}
+return new Uint8Array(byteNumbers);
+};
+
+// setting request headers for uploader
+var uploader = new 
Windows.Networking.BackgroundTransfer.BackgroundUploader();
+uploader.method = httpMethod;
+for (var header in headers) {
+if (headers.hasOwnProperty(header)) {
+uploader.setRequestHeader(header, headers[header]);
+}
+}
+
+if (isMultipart) {
+// adding params supplied to request payload
+var multipartParams = '';
+for (var key in params) {
+if (params.hasOwnProperty(key)) {
+multipartParams += LINE_START + BOUNDARY + 
LINE_END;
+multipartParams += "Content-Disposition: 
form-data; name=\"" + key + "\"";
--- End diff --

None I've found for Windows and `createUploadFromStreamAsync`. 

I think the current approach works as it is consistent with 
[Android](https://github.com/apache/cordova-plugin-file-transfer/blob/a9470ff1cc313be542f625f857d33fb14a520d6f/src/android/FileTransfer.java#L385-L411)
 and [iOS 
code](https://github.com/apache/cordova-plugin-file-transfer/blob/a9470ff1cc313be542f625f857d33fb14a520d6f/src/ios/CDVFileTransfer.m#L197-L225)
 for multipart forms and allows a fine tuning.

Alternative could be saving to a temporary file and using 
`BackgroundTransferContentPart` but it will be less efficient.



> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
> 

[jira] [Commented] (CB-9837) Add data URI support to file-transfer upload on iOS

2015-12-09 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/CB-9837?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15048942#comment-15048942
 ] 

ASF GitHub Bot commented on CB-9837:


GitHub user daserge opened a pull request:

https://github.com/apache/cordova-labs/pull/11

CB-9837 Add data URI support to file-transfer upload on iOS

Increases direct upload limit to the test image size

[Jira issue](https://issues.apache.org/jira/browse/CB-9837)

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/daserge/cordova-labs cordova-filetransfer

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cordova-labs/pull/11.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #11


commit cf3dc1a462cd2245a216f5a54155ea4f93278122
Author: daserge 
Date:   2015-12-09T16:33:41Z

CB-9837 Add data URI support to file-transfer upload on iOS

Increases direct upload limit to the test image size




> Add data URI support to file-transfer upload on iOS
> ---
>
> Key: CB-9837
> URL: https://issues.apache.org/jira/browse/CB-9837
> Project: Apache Cordova
>  Issue Type: New Feature
>  Components: Plugin File Transfer
>Reporter: Juan Antonio
>  Labels: ios, reproduced, triaged
>
> When I send an encoded base64 string image from iOS device with 
> 'data:image/jpeg;base64,' at the beginning of data image on 
> ft.upload(fileURL...) , plugin file transfer crash. However, on android works 
> perfectly ONLY if line 'data:image/jpeg;base64,' is present.
> Possible solution:
> If I delete string data 'data:image/jpeg;base64,' for iOS devices and modify 
> plugin file iOS 'CDVFileTransfer.m' like this:
> - (void)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
> {
> NSString* source = (NSString*)[command argumentAtIndex:0];
> NSData *fileData = [[NSData alloc] initWithBase64EncodedString:source 
> options:NSDataBase64DecodingIgnoreUnknownCharacters];
> [self uploadData:fileData command:command];
> }
> works perfectly, but it wouldn't accept image path, only base64 string 
> encoded images.
> Thanks.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org