This content has been marked as final. Show 3 replies
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.
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?
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).