3 Replies Latest reply on May 10, 2008 1:41 AM by slaingod

    Download a file without a dialog box

    Fantasma414
      Hello:
      I'm tryng to download an image and showing it in an image control of a flex 2 or 3 application. In the FileIO example I get this fr = new FileReference(); and later use this fr.download(request); this download method shows a dialog box asking the user where to put the image file. My question is this: how can I download an image file, put it in an image control without asking the user where to download the image file?
      Thank you.
        • 1. Re: Download a file without a dialog box
          Sreenivas R Adobe Employee
          Due to security reasons this is not allowed in flash player. You have to employ either sockets or some other mechanism to download the image. FileReference would always show the dialog.
          • 2. Re: Download a file without a dialog box
            Fantasma414 Level 1
            Guys:
            So there's no way to make a dynamic image gallery with images saved in a varbinary field of an SQL Server database?
            I thought to use a .NET web service to transform the varbinary into an image file and then download this file into the users machine, but It's a nightmare ask the user for every image where he whants to put it. Any ideas, suggestions?
            Thanx!
            • 3. Download a file without a dialog box
              slaingod Level 1
              Not sure exactly what you are trying to do. Download in Flex parlance usually means 'Save to disk on the user's machine' which rightly is not allowed for security reason without some user confirmation (Save As dialog).

              However, if you intention is simply to read some data from a sql db and show the images in a Flex app, that is doable. There are a couple of ways to do it, one which is more server-side and one that is more client-side.

              The server side would be to have your server accept an Image source= request and have the source url handler return the data for the image from the database. Ie. set you source to http://something.com/images/1 and your server would interpret that url as a request to the db for row 1 in an images table and return that data in a format indistinguishable from having been read as a separate file from the file system.

              The other option is to have the raw data sent to the Flex app using Loader as a byte array, and then use loadBytes() to have the Loader object process the data into a Bitmap that could then be assigned to an Image. There are probably several ways to do it client side, but probably more complex than just having the server fake it.

              You could even do what I've done in the past and have the server zip the images in a *.zip file and then use FZip to read the images on the client (so only one connection needs to be made to read a bunch of small thumbnails...I've regularly used several thousand thumbnails in a single zip file this way).