Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7264] Android: HTTPClient not working for upload files (Parity)

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-02-14T23:29:03.000+0000
Affected Version/sRelease 1.8.0.1, Release 2.0.0
Fix Version/sSprint 2012-03, Release 2.0.0, Release 1.8.2
ComponentsAndroid
Labelsmodule_network, parity, qe-testadded
ReporterMauro Parra-Miranda
AssigneeBill Dawson
Created2012-01-17T14:48:30.000+0000
Updated2014-03-13T17:45:14.000+0000

Description

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. 

Comments

  1. Bill Dawson 2012-01-27

    Problem was that Resource files are not real files in the file system. Pull request ready https://github.com/appcelerator/titanium_mobile/pull/1291
  2. jithinpv 2013-11-25

    Anvil test case added. PR link: https://github.com/appcelerator/titanium_mobile/pull/5011

JSON Source