8 Replies Latest reply on Oct 24, 2010 2:53 PM by aktell2007

    How to download multiple files?

    flexillu10

      I have an air app where a user can click a thumbnail and download that file to their download folder.

       

      My question is how to go about allowing the user to select more than one and download them instead of one at a time.

       

      Do i need to just put the download in a loop? Also My custom item renderer and stopped the tiles from looking like they are selected, how would i make them look selected?

        • 2. Re: How to download multiple files?
          flexillu10 Level 1

          Link isn't working for me..

          • 3. Re: How to download multiple files?
            jfb00 Level 3

            mmm... it was working yesterday.

            Here is another example

            http://weblog.cahlan.com/files/file_uploads/FileUpload.html

             

            Johnny

            Please rate answers.

            • 4. Re: How to download multiple files?
              flexillu10 Level 1

              Thanks, but i think that is for like a download prompt, and select location.

               

              The dialog box wold take away from the app.

               

              At the moment the download is done by creating a file in the download folder and using a file stream to write the bytes to that file, i just need this done for more than one file at a time

              • 5. Re: How to download multiple files?
                Arun Ganesh Level 3

                try this

                 

                private function downloadFile(url:String):void{

                 

                            var urlStream:URLStream = new URLStream();

                 

                               var request:URLRequest = new URLRequest(url);

                 

                            downloadFileName=getDownloadFilename(url);

                 

                                  urlStream.addEventListener(Event.COMPLETE, writeFile);

                 

                                  urlStream.addEventListener(IOErrorEvent.IO_ERROR , function (e:IOErrorEvent):void{

                 

                                  });

                 

                                  urlStream.load(request);

                 

                            urlStream.addEventListener(IOErrorEvent.IO_ERROR, onIOError);

                 

                        }

                     private function getDownloadFilename(URL:String):String{
                            return(URL.substring(URL.lastIndexOf("/"),URL.length));
                        }

                       

                 

                        private function onIOError (e:IOErrorEvent):void

                 

                        {

                 

                            trace("An Error Occured and it looked like this.", e.text);

                 

                        }

                 

                       

                 

                         private function writeFile(event:Event):void {

                 

                             var fileStream:FileStream = new FileStream();

                 

                          

                 

                         

                 

                             var file:File=//perfered filename with location            

                 

                            fileStream.open(file, FileMode.WRITE);   

                 

                             var dataBuffer:ByteArray = new ByteArray();

                 

                            event.target.readBytes(dataBuffer, 0, event.target.bytesAvailable);

                 

                            fileStream.writeBytes(dataBuffer, 0, dataBuffer.length);

                 

                             fileStream.close();

                 

                            event.target.close();

                 

                            downloadFile(NEXT_ONE);

                 

                           }
                • 6. Re: How to download multiple files?
                  flexillu10 Level 1

                  can you help me getting the file name? the url's are stored in the selected items vector, how would i loop through the list of selected items and pass each url to the download function?

                  • 7. Re: How to download multiple files?
                    flexillu10 Level 1

                    Still looking for help with this, i want to download the items stored in the Spark list selected items, can anyone help?

                    • 8. Re: How to download multiple files?
                      aktell2007 Level 1

                      I was working about six to eight weeks ago on something like that

                      and I can remember that on FLEX Examples was some code !

                       

                      But in the end I used ZINK - MDM software which is free and I used some code from there DB and modified it and build the desyop app. which had multible file downloads in many different ways and with NO restrictions in file size.

                       

                      Maybe look at it and it is something you wanted ??? regards aktell2007