PROBLEM DESCRIPTION
Customer can't upload files thru HTTPClient from Android. Code is working perfect in iOS.
STEPS TO REPRODUCE
1. Create mobile project
2. Paste this code to app.js
var win = Ti.UI.createWindow();
var image = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'appc.jpg');
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function(e)
{
Ti.UI.createAlertDialog({title:'Error', message:e.error}).show();
Ti.API.info('IN ERROR ' + e.error);
};
xhr.setTimeout(20000);
xhr.onload = function(e)
{
Ti.UI.createAlertDialog({title:'Success', message:'status code ' + this.status}).show();
Ti.API.info('IN ONLOAD ' + this.status + ' readyState ' + this.readyState);
};
xhr.onsendstream = function(e)
{
Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress);
};
// open the client
xhr.open('POST','https://twitpic.com/api/uploadAndPost');
// send the data
xhr.send({media:image,username:'fgsandford1000',password:'sanford1000',message:'check me out'});
win.open();
3. Run this on Android
ACTUAL RESULTS
The upload is not working
EXPECTED RESULTS
The upload working fine, as in iOS.
Problem was that Resource files are not real files in the file system. Pull request ready https://github.com/appcelerator/titanium_mobile/pull/1291
Anvil test case added. PR link: https://github.com/appcelerator/titanium_mobile/pull/5011