I have a Cordova app for iOS, which I'm now updating to support Android. I have most of the issues worked out, but the FileTransfer plugin is not including FileUploadOptions.params in the request. Everything works smoothly on iOS. With Android, the request is sent, and everything seems normal except the request that reaches the server has no form fields.
I have set a breakpoint just before calling the upload method, and the options.params object looks correct.
I'm testing with Android 4.4.3, Cordova 3.5, and FileTransfer plugin 0.4.4. The server is running Apache and has SSL enabled.
Here is my code:
var options = new FileUploadOptions();
options.chunkedMode = false;
options.mimeType = 'audio/mp4';
options.fileKey = 'file';
options.fileName = filename;
options.params = {
'siteId': siteId,
'name': nameFld.getValue(),
'date': sqlDate,
'length': Math.round(storyLength)
};
options.headers={'Authorize': token};
var ft = new FileTransfer();
ft.upload(path, url, uploadSuccess, uploadFail, options);
I found the same issue here, with no response: Phonegap fileTransfer upload doesn't POST params
UPDATE: Opened an issue for this here: https://issues.apache.org/jira/browse/CB-7171
The key to making it work set the option.headers:
options.headers = {
Connection: "close"
}
Phonegap File Transfer of picture fails on every other picture: Error code 3 with FileTransfer upload
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With