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
I got it working; it turns out I was wrong about the file being successfully transferred. Due to some confusion about the Android file system, I was using the wrong file path.
The plugin did not raise an error in the JavaScript console, and proceeded to make the request without data attached. Once I checked the error messages in the Dalvik Debug Monitor, I was able to track down the problem.