0 Replies Latest reply on Apr 30, 2009 2:34 AM by Buch90

    Need some help downloading html files

    Buch90

      Hiya,

       

      I am currently trying to develop an app where I can download some html files with tables in and that is all. No user interaction needed.

      But the thing is having to download theese files I currently use a lot of code becasue I have to download 52 files.

       

      My current try which works fine is similair to below:

      function download(){
      var u1h = new air.URLRequest("http://domain.com/file1.html");
      var u2h = new air.URLRequest("http://domain.com/file2.htm"); 
      var u3h = new air.URLRequest("http://domain.com/file3.htm");
      
      var u1f = air.File.documentsDirectory.resolvePath( 'App/dir/file1.html' );
      var u2f = air.File.documentsDirectory.resolvePath( 'App/dir/file2.htm' );
      var u3f = air.File.documentsDirectory.resolvePath( 'App/dir/file3.html' );
      
      var loader = new air.URLLoader(); 
      loader.load(u1h);
      loader.load(u2h);
      loader.load(u3h);
      
      var stream = new air.FileStream();
      stream.open( u1f, air.FileMode.WRITE );
      stream.writeMultiByte( u1h, air.File.systemCharset );
      
      stream.open( u2f, air.FileMode.WRITE );
      stream.writeMultiByte( u2h, air.File.systemCharset );
      
      stream.open( u3f, air.FileMode.WRITE );
      stream.writeMultiByte( u3h, air.File.systemCharset );
      stream.close();
      }
      

       

      From above I achieve the effect I want to and download and save the files, but to be honest I am very new and have been using the last week trying to figure out an easier way to achieve the same function. I have been thinking of loops inside a function but really I have tried with a few diffrent things but they won't for me. So if anyone has an idea to this it would be really nice

       

      EDIT: Just found out that the content I get is: [object URLRequest], Damn then I don't know what to do

       

      Another thing then is if there is a way to make this more dynamic even to get all files from a web directory and download and save.

      Best Regards

      Buch