The photo is not uploaded to the server if the data size is bit high. I have attached four photos, among them only first photo(37k) is uploaded to the server and rest of the photo call onerror function. But on android, all the photo is uploaded successfully.
1. Create a new App
2. Run the following code to the device
var win = Ti.UI.createWindow({
backgroundColor: 'Green',
layout: "vertical"
});
// Create a Button.
var Gallery = Ti.UI.createButton({
title: 'Opne Gallery',
height: Ti.UI.SIZE,
width: Ti.UI.SIZE,
top: 50,
});
win.add(Gallery);
var ind = Titanium.UI.createProgressBar({
width: 200,
height: 50,
min: 0,
max: 1,
value: 0,
// style: Titanium.UI.ios.ProgressBarStyle.PLAIN,
top: 20,
message: 'Uploading image',
font: { fontSize: 12, fontWeight: 'bold' },
color: '#888'
});
win.add(ind);
Gallery.addEventListener('click', function(e) {
Titanium.Media.openPhotoGallery({
success: function(event) {
//upload(event);
ind.show();
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function(e) {
Ti.UI.createAlertDialog({
title: 'Success',
message: 'status code ' + this.status
}).show();
};
xhr.onerror = function(e) {
Ti.API.info('post,E.ERROR:' + e.error);
alert('post,E.ERROR:' + e.error);
};
xhr.onsendstream = function(e) {
ind.value = e.progress;
Ti.API.info('ONSENDSTREAM - PROGRESS: ' + e.progress);
};
xhr.open("POST", "https://mobile.cycu.edu.tw/api/sos/panic/");
xhr.send({
"app_id": '3',
"app_token": 'BEDF0C6702',
"access_id": '181',
"access_token": '181',
"coord": '',
"file": event.media
});
},
cancel: function() {
// called when user cancels taking a picture
// alert("cancel");
},
error: function(error) {
// called when there's an error
alert("error: " + error);
},
saveToPhotoGallery: false,
animated: true,
//overlay: true,
// allowEditing and mediaTypes are iOS-only settings
// allowEditing : false,
mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO] // Ti.Media.MEDIA_TYPE_VIDEO,
});
});
win.open();
I am unable to reproduce this with any other endpoint. Here is an example of using
httpbin
, the leading HTTP-testing service:Output:
I've sent 3 image via the gallery (all about 400-1200kb size) and it worked without any issues. I need to try this specific images, but I don't expect it to happen different. Besides that, we recently tried even with blobs having a size of 15 MB and more for TIMOB-24364, which has gone through both our QE testing and the reports QE cycle. If something was wrong with our API, that would have popped up there or inside our general unit-tests.