cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oddcb <>
Subject [GitHub] cordova-plugin-file-transfer pull request: CB-11067 - Adds content...
Date Thu, 26 May 2016 10:51:59 GMT
Github user oddcb commented on the pull request:
    Thanks for you reply @daserge 
    So I'm not very into how file uploads are done properly, but the problem I fixed for our
api here was adding the Content-Length into the code block starting at: 
                        beforeData.append("Content-Disposition: form-data; name=\"").append(fileKey).append("\";");
                        beforeData.append(" filename=\"").append(fileName).append('"').append(LINE_END);
                        if(filesize > -1)
                            beforeData.append("Content-Length: ").append(filesize).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");
                        int stringLength = beforeDataBytes.length + tailParamsBytes.length;
    As far as I can tell it is also what happens for iOS in
    ``` [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Length: %ld\r\n\r\n",
(long)[fileData length]] dataUsingEncoding:NSUTF8StringEncoding]];```
    History for us is just that our ios app was working with the file upload plugin as is,
but when we added the android app with the plugin it did not send Content-Length as iOS did
and hence our file upload API started to scream. We are using Jersey in our backend.
    As far as I can tell your opinion is that this added code should not be required interacting
with a standard api?

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message