Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

iPad image download&save

Hello, I've got some more questions as I'm trying to make some example app.
So now I've run into this kind of problematic part,
I can create ImageView and first time load image from URL, but than I would like to store it locally (or if there is any other way to download images to iPad tell me please).

the code so far does load the image and show it, which would be really annoying if for example there would be hundreds of them and I would need to download&save them.

            var image = Titanium.UI.createImageView({image:'http://some.url.to/image/file.png'});
                image.addEventListener('load',function (){    
                    f.write(image.toImage());
                });

Is there any more efficient way to download images from server to iPad and store them as any kind of package ? Thanks in advance

— asked October 7th 2010 by Lukas Skrabak
  • download
  • file
  • image
  • ipad
0 Comments

1 Answer

  • Try the function in this post.

    http://developer.appcelerator.com/question/45471/how-to-save-a-remote-imagepicture-to-database-or-filesystem

    The first parameter is the filename to store the image to. I basically store it in the documents folder and use this function Ti.Utils.md5HexDigest(url) to convert the URL to an MD5 hash so you get a semi-unique name. The next parameter is the path the file you are trying to fetch and the third and fourth are used to tell when the download is complete and progress.

    Hope this helps.

    — answered October 7th 2010 by John McKnight
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.