Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12589] Android: Blob has wrong Content-Type & file extension name when send via HTTPClient

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterJong Eun Lee
AssigneeUnknown
Created2013-01-14T21:22:21.000+0000
Updated2018-02-28T20:03:36.000+0000

Description

Repro sequence

Ti.Media.openPhotoGallery({
    success : function(event) {
    	var alertText = '';
		var image = event.media;
		
		alertText += image.mimeType + '\n';
		alertText += image.imageAsThumbnail(200).mimeType + '\n';
		
		var imageView = Ti.UI.createImageView({
			image : image
		});
		alertText += imageView.toBlob().mimeType + '\n';
		alert(alertText);
		
		//exam request multipart 'image' property. It has a txt.filename (tixhr-xxxxxx.txt), why txt?;
		var xhr = Ti.Network.createHTTPClient();
		xhr.open("POST", 'http://www.google.com');
		xhr.setRequestHeader("enctype", "multipart/form-data;");
		xhr.send({
			image : imageView.toBlob()
		});
	},
	mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
});

iOS Alert result:

image/jpeg
image/jpeg
image/jpeg

Android alert result:

image/jpeg
image/bitmap
image/bitmap

Additional info

Attached request multipart screenshots

Attachments

FileDateSize
android.png2013-01-14T21:22:21.000+00007775
ios.png2013-01-14T21:22:21.000+000011169

Comments

  1. Eduardo Gomez 2013-02-02

    What is your Android OS device/emulator version?
  2. Jong Eun Lee 2013-02-05

    tested only devices. Galaxy 3(SH-E210S, Android 4.0.4) Galaxy Nexus (Android 4.1.1.)
  3. me@gmail.com 2014-02-19

    This is still an issue in 3.2.1.GA
  4. Rodrigo Pavez 2015-01-06

    The problem is also present in 3.4.0.GA. In my case even when the file is a JPEG, XHR its sending it as BMP (Tested in Motorola Moto G XT1032). My only workaround its just add the bmp extension even when its JPEG and let the browser guess the right mime-type then but its clearly not a good solution.
  5. Arjan 2017-02-02

    Also got this problem. Working with SDK 6.0.2, tried multiple simulators, same issue.

JSON Source