Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova FileTransfer plugin params empty on Android

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

like image 658
bjudson Avatar asked Jan 28 '26 18:01

bjudson


1 Answers

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

like image 132
Varun Nath Avatar answered Jan 31 '26 08:01

Varun Nath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!