is httpclient setFile broken

You must Login before you can answer or comment on any questions.

httpclien's setFile on iPhone used to be able to download large file without breaking memory, but when I tested it today, it doesn't seem to work that way anymore, I am on latest 2.1.1GA sdk. if it is saving the bytes to file, there should be an intermediate file showing up, however, the file only shows when it finishes downloading.

— asked 10 months ago by jason hu
1 Comment
  • I checked the generated object c code in build dir, it looks like it is still doing the correct thing, it does call "setDownloadDestinationPath" in request.

    — commented 10 months ago by jason hu

1 Answer

Accepted Answer

Hi Jason

Can I confirm that you are calling the setFile method only AFTER you use the open method?

More information about Titanium.Network.HTTPClient-property-file

— answered 10 months ago by Malcolm Hollingsworth
answer permalink
8 Comments
  • I mentioned I was able to get the file, so I definitely put the setFile between open and send. I tried to retrieve a 100MB file, during downloading, I didn't the file was created, then after 2 mins, then whole just showed up in one shot, that indicates it is still storing the data in memory and then writes its memory into a file once it is done, this behavior is definitely not what we want to see.

    — commented 10 months ago by jason hu

  • So I can create a test - can you let me know what sort of file you are downloading that is that large? Binary like jpg, png or zip, or text like txt, Jason, XML?

    So text or binary?

    — commented 10 months ago by Malcolm Hollingsworth

  • it is a dummy mp4 video, but I don't think the file format matters much though. Here is my simple sample code. I expect to see the intermediate file created and its size incrementing during downloading, but the file shows up with complete size once download is over.

    var c = Titanium.Network.createHTTPClient();
    c.ondatastream = function(e) { Ti.API.info('ONDATASTREAM1 - PROGRESS: ' + e.progress); };
    c.onerror = function(e) { alert('Failed to download'); };
    //smaller file
    c.open('GET', 'http://media.jilion.com/videos/demo/midnight_sun_sv1_720p.mp4');
    //large file
    //c.open('GET', 'http://184.107.135.242/data1/125928.mov');

    c.file = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, 'dummy.mp4');
    c.send();

    — commented 10 months ago by jason hu

  • Show 5 more comments

Your Answer

Think you can help? Login to answer this question!