Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24678] iOS: Only small size photo is uploaded to the server using HTTPClient.

GitHub Issuen/a
TypeBug
PriorityNone
StatusResolved
ResolutionCannot Reproduce
Resolution Date2018-07-26T14:55:49.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
LabelsHTTPClient, photogallery
ReporterMotiur Rahman
AssigneeHans Knöchel
Created2017-05-11T06:38:27.000+0000
Updated2018-07-26T14:55:49.000+0000

Description

Description

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.

Steps to Reproduce

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();
Thanks

Attachments

FileDateSize
37K.png2017-05-11T06:07:10.000+000036092
4.2M.png2017-05-11T06:08:13.000+00004235994
577K.png2017-05-11T06:07:22.000+0000578066
8.4M.png2017-05-11T06:09:50.000+00008416840

Comments

  1. Hans Knöchel 2017-05-11

    I am unable to reproduce this with any other endpoint. Here is an example of using httpbin, the leading HTTP-testing service:
       var win = Ti.UI.createWindow({
           backgroundColor: 'Green',
           layout: "vertical"
       
       });
       
       var Gallery = Ti.UI.createButton({
           title: 'Open Gallery',
           top: 50
       });
       
       win.add(Gallery);
       
       var ind = Titanium.UI.createProgressBar({
           width: 200,
           min: 0,
           max: 1,
           value: 0,
           top: 20,
           message: 'Uploading image',
       });
       
       win.add(ind);
       
       Gallery.addEventListener('click', function(e) {
           Ti.Media.openPhotoGallery({
               success: function(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', 'http://httpbin.org/post');
       
                   xhr.send({
                       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);
               },
               mediaTypes: [Ti.Media.MEDIA_TYPE_PHOTO]
           });
       });
       
       win.open();
       
    Output:
       2017-05-11 12:40:27.111 Titanium[2682:159030] [DEBUG] Application booted in 180.882990 ms
       2017-05-11 12:40:33.872227+0200 Titanium[2682:159030] [Generic] Creating an image format with an unknown type is an error
       2017-05-11 12:40:34.905 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.004124567378312349
       2017-05-11 12:40:35.680 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.1196124479174614
       2017-05-11 12:40:36.177 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.15673355758190155
       2017-05-11 12:40:36.702 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.18973009288311005
       2017-05-11 12:40:37.173 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.2268511950969696
       2017-05-11 12:40:38.145 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.2680968642234802
       2017-05-11 12:40:39.134 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.3382145166397095
       2017-05-11 12:40:40.054 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.40420758724212646
       2017-05-11 12:40:40.951 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.47020065784454346
       2017-05-11 12:40:41.845 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.5361937284469604
       2017-05-11 12:40:42.564 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.6021867990493774
       2017-05-11 12:40:43.242 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.6681798696517944
       2017-05-11 12:40:44.049 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.7341729998588562
       2017-05-11 12:40:44.773 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.8001660704612732
       2017-05-11 12:40:45.487 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.8661591410636902
       2017-05-11 12:40:46.569 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.9321522116661072
       2017-05-11 12:40:47.364 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.9981452822685242
       2017-05-11 12:40:56.592 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 1
       2017-05-11 12:40:57.041 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.1938546597957611
       2017-05-11 12:40:57.436 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.23097576200962067
       2017-05-11 12:40:58.325 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.2680968642234802
       2017-05-11 12:40:59.042 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.34233906865119934
       2017-05-11 12:40:59.971 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.4083321690559387
       2017-05-11 12:41:00.676 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.4743252396583557
       2017-05-11 12:41:01.406 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.5403183102607727
       2017-05-11 12:41:02.116 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.6063113808631897
       2017-05-11 12:41:03.024 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.6723044514656067
       2017-05-11 12:41:03.772 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.7382975220680237
       2017-05-11 12:41:04.494 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.8042905926704407
       2017-05-11 12:41:05.200 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.8702837228775024
       2017-05-11 12:41:05.903 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.9362767934799194
       2017-05-11 12:41:06.652 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 1
       2017-05-11 12:42:47.165 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.0025967087130993605
       2017-05-11 12:42:48.179 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.0753045529127121
       2017-05-11 12:42:48.986 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.09607822448015213
       2017-05-11 12:42:49.972 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.11944860219955444
       2017-05-11 12:42:50.908 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.14281898736953735
       2017-05-11 12:42:52.472 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.16618935763835907
       2017-05-11 12:42:53.885 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.2129301130771637
       2017-05-11 12:42:54.838 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.25447747111320496
       2017-05-11 12:42:55.565 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.29602479934692383
       2017-05-11 12:42:56.471 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.3375721275806427
       2017-05-11 12:42:57.209 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.37911948561668396
       2017-05-11 12:42:57.912 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.42066681385040283
       2017-05-11 12:42:58.623 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.4622141420841217
       2017-05-11 12:42:59.383 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.5037614703178406
       2017-05-11 12:43:00.078 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.5453088283538818
       2017-05-11 12:43:00.777 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.5868561863899231
       2017-05-11 12:43:01.466 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.6284035444259644
       2017-05-11 12:43:02.290 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.6699508428573608
       2017-05-11 12:43:02.987 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.7114982008934021
       2017-05-11 12:43:03.731 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.7530455589294434
       2017-05-11 12:43:04.443 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.7945928573608398
       2017-05-11 12:43:05.161 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.8361402153968811
       2017-05-11 12:43:05.913 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.8776875734329224
       2017-05-11 12:43:06.614 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.9192348718643188
       2017-05-11 12:43:07.312 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 0.9607822299003601
       2017-05-11 12:43:08.136 Titanium[2682:159030] [INFO] ONSENDSTREAM - PROGRESS: 1
       
    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.

JSON Source