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

ASF GitHub Bot commented on CB-11067:
-------------------------------------

GitHub user oddcb opened a pull request:

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

    CB-11067 - Adds content-length to multipart string if file length 
determined as also iOS plugin does

    ICLA signed and sent per email.
    
    https://issues.apache.org/jira/browse/CB-11067

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

    $ git pull https://github.com/oddcb/cordova-plugin-file-transfer 
CB-11067_add_file_content_length_to_multipart_if_present

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

    https://github.com/apache/cordova-plugin-file-transfer/pull/140.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 #140
    
----
commit 7673590ad65a673c7578f7eead78fd4bd083f05c
Author: Odd Christer Brovig <o...@systemfabrikken.org>
Date:   2016-04-13T08:10:16Z

    CB-11067 - Adds content-length to multipart string if the file length is 
determined, as also the iOS plugin does.

----


> Content-Length missing in multipart form upload header on Android
> -----------------------------------------------------------------
>
>                 Key: CB-11067
>                 URL: https://issues.apache.org/jira/browse/CB-11067
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin File Transfer
>         Environment: Plugin version 1.5.0
> chunked = false
>            Reporter: Odd Christer Brovig
>
> On iOS Content-Length is sent as part of header for multipart form. On 
> Android only Content-Disposition and Content-Type is sent.
> Is there a special reason for this? I see that the file size is read after 
> the beforeData is converted to bytes.
> From FileTransfer.java:
> {code:java}
>                     
> beforeData.append(LINE_START).append(BOUNDARY).append(LINE_END);
>                     beforeData.append("Content-Disposition: form-data; 
> name=\"").append(fileKey).append("\";");
>                     beforeData.append(" 
> filename=\"").append(fileName).append('"').append(LINE_END);
>                     beforeData.append("Content-Type: 
> ").append(mimeType).append(LINE_END).append(LINE_END);
>                     byte[] beforeDataBytes = 
> beforeData.toString().getBytes("UTF-8");
>                     byte[] tailParamsBytes = (LINE_END + LINE_START + 
> BOUNDARY + LINE_START + LINE_END).getBytes("UTF-8");
> {code}
> From CDVFileTransfer.m:
> {code}
>     [postBodyBeforeFile appendData:formBoundaryData];
>     [postBodyBeforeFile appendData:[[NSString 
> stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; 
> filename=\"%@\"\r\n", fileKey, fileName] 
> dataUsingEncoding:NSUTF8StringEncoding]];
>     if (mimeType != nil) {
>         [postBodyBeforeFile appendData:[[NSString 
> stringWithFormat:@"Content-Type: %@\r\n", mimeType] 
> dataUsingEncoding:NSUTF8StringEncoding]];
>     }
>     [postBodyBeforeFile appendData:[[NSString 
> stringWithFormat:@"Content-Length: %ld\r\n\r\n", (long)[fileData length]] 
> dataUsingEncoding:NSUTF8StringEncoding]];
> {code}



--
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

Reply via email to