2 Replies Latest reply on Apr 24, 2009 1:34 AM by chocoanzak

    Downloading in Flex

    chocoanzak

      Hi,

       

      I am currently looking at the possibilites of downloading in Flex. I have a Client/Server set up where a file is produced on the server and then downloaded  in to the browser where the Flex client is sitting. However, I have had a number of issues with the set up of different browser (IE especially) therefore if I could keep all the functionality inside the flash player that would be ideal.

       

      I originally looked at the FileReference class and have found this ideal for downloading files directly to the user's hard drive. However, I also have the requirement to open a file using the user's default application.

       

      This would involve

      1) Downloading the content of the files (as a ByteArray) into Flex

      2) Binding it as a generic file type object

      3) Passing the object to the Browser so it can handle the opening of it

       

      I have successfully achieved retrieving and storing the ByteArray from the server but can not find any documentation on the further steps. I have read a lot about security issues but I wouldn't have thought that prompting the user for a file download was an issue (though I could be wrong on that one). I have found evidience it is possible in Adobe Air but the deployment of my application means I am limited to the Flash Player.

       

      Would anyone be able to suggest a way forward on this? I would really like to achieve a solution in Flex as I found it a very versatile language. If there isn't a solution any ideas if Adobe will support this in future. It seems like a good feature to have.

       

      Regards,

      William

        • 1. Re: Downloading in Flex
          Madhav Subedi Level 4

          Does simply telling browser to navigate to that file works for you?

          if so, then try following:

           

          navigateToURL(new URLRequest('file.zip'),'_blank')

           

          or

           

          navigateToURL(new URLRequest('a.txt'),'_blank')

           

          so that the browser handles it according to the file type.

          1 person found this helpful
          • 2. Re: Downloading in Flex
            chocoanzak Level 1

            Thanks for the reply. I am currently looking at the route you suggested but I found so

            many issues with cross browser compatibility that I was hoping an internal flex solution

            could solve my problem.

             

            I found an interesting article similar to your suggestion a while ago and the publisher managed

            to get downloading (from links) working across the browsers. However, testing it using IE7 now

            seems to break it.

             

            If anyone is interested:

            (http://thesaj.wordpress.com/2008/02/12/the-nightmare-that-is-_blank-part-ii-help/)

             

            I will endeavor to find a solution but alas I fear it will be using the browser and download links

            rather than inside flex.