Titanium JIRA Archive
Appcelerator Community (AC)

[AC-400] HTTPClient POST request with file doesn't work on Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionCannot Reproduce
Resolution Date2015-11-11T18:45:11.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labels5.0.0.GA
ReporterDavid Vermeir
AssigneeMostafizur Rahman
Created2015-09-29T08:21:41.000+0000
Updated2015-11-11T18:45:11.000+0000

Description

When trying to do a POST request in Titanium 5.0.0GA, it works as long as you don't include a file. As soon as a file is included the body of the POST is empty on arrival on the server but the file is still there. This issue only seems to occur on Android, iOS has no problems. I've posted this issue on the Community Q&A and other users seem to be having the same problems.

Comments

  1. David Vermeir 2015-09-29

       var mediaParams = {
       			success : function(event) {
       				var imageBlob = event.media;
                                       register(imageBlob);
       			},
       			cancel : function() {
       				
       			},
       			error : function() {
       				
       			}
       		};
       Titanium.Media.openPhotoGallery(mediaParams);
       
       function register(image) {
               var registerData = {
                    username:'test',
                    avatar:image
               };
       
       	var xhr = Ti.Network.createHTTPClient();
       	xhr.onload = function() {
       		//...
       	};
       	xhr.onerror = function(error) {
                        //...
       	}; 
       
       	xhr.open('POST', 'http://foo.com/register');
       	
       	xhr.send(registerData);
       }
       
  2. Aminul Islam 2015-11-11

    Hi , I tested the issue you reported . I can't reproduce it .HTTPClient POST request with file is working fine for me . *Test Code*
       function file_transmit(blob) {
       	url = 'http://abc/send_email.php';
       	var client = Ti.Network.createHTTPClient({
       		onload : function(e) {
       			var json = JSON.parse(this.responseText);
       			Ti.API.info('this.responseText' + this.responseText);
       			if (json.success === true) {
       			} else {
       			};
       		},
       		onerror : function(e) {
       			Ti.API.debug(e.error);
       		},
       	});
       	Ti.API.info('blob' + blob);
       	client.open("POST", url);
       	var params = {
       		fileUri : blob
       	};
           client.send(params);
       }
       
    Environment
       Operating System
         Name                        = Mac OS X
         Version                     = 10.10.5
         Architecture                = 64bit
         # CPUs                      = 4
         Memory                      = 8589934592
       Node.js
         Node.js Version             = 0.10.37
         npm Version                 = 1.4.28
       Titanium CLI
         CLI Version                 = 5.0.5
       Titanium SDK
         SDK Version                 =5.0.2 GA
         SDK Path                    = /Users/Library/Application Support/Titanium/mobilesdk/osx/5.0.2 GA
         Target Platform             = android
       
    Thanks

JSON Source