FileReference – A petition for Astro !

André Michelle posted a few days ago a petition concerning the onSoundComplete event. This gave me an idea concerning the API we have currently in the Flash Player 9.

One of the most disappointing thing we have when playing with bytes in the Flash Player 9 is the FileReference API. Let's say you call the FileReference.browse() method to select a file.

Once selected, you have no way to get a ByteArray from it directly.

Of course you have the following solution :

First, you have to upload the file to your server, then you have to download it with the class as a binary file (URLLoaderDataFormat.BINARY), and then you'll get the bytes.

This means that for any Flash online image editing application, you will have to upload your bitmap first, and then download it before having fun with the application. I would like to introduce a new method in the AlivePDF library so that you can embed any image stream easily. The current Flash Player doesn't facilitate that.

Same limitation with the GIFPlayer library and ASZip.

Now, even worse.

There is no way to save a generated ByteArray on the hard disk through the FileReference API. Once again, you will have to upload it, and then ask to a server side script to spit it out back to the browser with appropriate headers so that it shows a download box window.

But guess who does allow all of this ? ;)

Here is how you would get the bytes from a selected file in Silverlight 1.1 with the OpenFileDialog class :

Stream fileStream = browseDialog.SelectedFile.OpenRead();
byte[] funkyBytes = new byte[fileStream .Length];
fileStream.Read(funkyBytes, 0, (int)fileStream.Length);

The final release of Silverlight 1.1 will also include a SaveFileDialog class. This should allow us to save runtime streams locally through a save-as dialog window.

As would say André, please leave a comment. Let's bring that in the Flash Player 10, that would rock.

Please Adobe ;)

Update : This feature is available in the Flash Player 10 ;)

Comments (57)

  1. jeff wrote:

    I would like to add my vote for this feature.

    Saturday, December 22, 2007 at 6:13 am #
  2. Rezmason wrote:

    Hear, hear! I would greatly appreciate this functionality – not enough to try Silverlight, but still, I would approve a change, and would welcome some dialogue with Adobe on this matter. I first figured that the absence of this feature was due to some security constraint, but now I believe that that is an independent concern.

    Saturday, December 22, 2007 at 6:30 am #
  3. felix wrote:

    I imagine this is a security restriction. AIR allows you to read and write byteArrays to the HD via the FileStream class.

    Saturday, December 22, 2007 at 6:53 am #
  4. Shannon wrote:

    I totally agree… Having to upload & download files before being able to do anything with them in the player is a PITA. Sure, there are security implications, but with forced OS-level choose and save dialog boxes, those concerns are minimal.

    Saturday, December 22, 2007 at 8:33 am #
  5. Tangent wrote:

    I wonder if it is by-design that ByteArray cannot be read on files coming from user’s hard drive? Wouldn’t it be part of the security requirement? I certainly don’t want any Flash movies sniffing on contents of my files.

    Saturday, December 22, 2007 at 8:50 am #
  6. julien wrote:

    Agreed! That would be awesome

    Saturday, December 22, 2007 at 11:37 am #
  7. Jérôme wrote:

    Competition is good. If Microsoft add this to Silverlight, Adobe will probably be forced to do the same thing.
    Thanks for posting this petition.

    Saturday, December 22, 2007 at 11:45 am #
  8. lionel wrote:

    I dream about this feature :)

    Saturday, December 22, 2007 at 1:57 pm #
  9. Thibault Imbert wrote:

    Hi everybody,

    Thanks for giving your opinion :)

    Felix >> Of course there are security implications, but let’s find a solution :)
    AIR allows this, but every online RIA would take huge benefits with such a feature.

    Tangent >> The player wouldn’t be able to get your file content if you haven’t selected it through a browse window :)

    Saturday, December 22, 2007 at 3:04 pm #
  10. I agree, but I think this is the result of a much broader issue : the flash player security model has to evolve to allow that kind of operations.
    Now, about the petition, shouldn’t we just fill a feature request form? Is there any equivalent to Flex’s Jira for the flash player?

    Saturday, December 22, 2007 at 3:20 pm #
  11. Joa Ebert wrote:

    I agree with Thibault. If Adobe is not able to embed this basic functionality at a given point anyone might switch to Silverlight to develop a user-friendly and complex RIA.

    I want to see some fruits from the competition that are not only video releated please!

    Saturday, December 22, 2007 at 3:26 pm #
  12. Mr.doob wrote:

    Yes, please!

    Saturday, December 22, 2007 at 3:32 pm #
  13. Tek wrote:


    I really want to know from Adobe or to discuss what could be the security issues with this feature. I can’t see more limitation with it than from downloading a file from the internet.

    Problem could be with the implementation. Actually the download file feature uses the browser API to download the file. I’m not sure that it is so easy to create a download dialog in the browser for a file that did not came from the browser cache. It could be a security problem too. Does Silverlight 2.0 will uses browser cache before displaying a save file dialog ?

    Saturday, December 22, 2007 at 3:34 pm #
  14. Tink wrote:

    This has been a requested since the very introduction of FileReference. I’ll add myself to the vote again, but can’t help agreeing with david here.

    If you log your bugs/requests in the system Adobe have in place, then get people to cast votes on that request, it will be a lot easier for Adobe to track the issue, and therefore more likely that it gets addressed if they feel they can.

    Saturday, December 22, 2007 at 5:57 pm #
  15. Thibault Imbert wrote:

    Hi Tink,

    Yes I will do that, It’s just in case some Adobe people are reading this ;)

    Saturday, December 22, 2007 at 6:05 pm #
  16. Drew wrote:

    this has driven me crazy on multiple occasions. of course we could nip 90% of flash player annoyances if someone went after the root of the problem- its ridiculous security model.

    Saturday, December 22, 2007 at 7:26 pm #
  17. dandaniz wrote:

    i am sorry about my eng
    why we will not build some light app
    in c++ that it will be a server
    and the user will download this one
    and all the restriction that flash
    has it will solve

    Sunday, December 23, 2007 at 1:58 am #
  18. MilGra wrote:

    I totally agree. But till that, as dandaniz wrote, maybe we can use Milenia for file operations on the same machine besides p2p capabilities.


    Sunday, December 23, 2007 at 12:39 pm #
  19. dandaniz wrote:

    i wrote a little app in c++
    that it has an ability of rtmp and it can communicate with flash
    and it has cross-domain ability
    if we build some grate one it will be huge we will can to build p2p
    video chat we will can also save file in the user computer and some more
    all we have to do is to
    encourage user to download this little app

    Sunday, December 23, 2007 at 2:49 pm #
  20. Bjorn wrote:

    I dont agree with Tink. This is a major limitation that should not require a petition or damn community feature request logged before anything gets down..

    Like my main man Clubber Lang said, ‘ITS ALL POLITICS MAN’

    Thanks Thi for letting us know it can be done in SL

    Monday, December 24, 2007 at 10:10 am #
  21. Ryan wrote:

    This would be nice. There are security issues around the sandbox but… The FileReference and FileRefernceList classes are killer though compared to what was there before, at least you can upload and select multiple files. In silverlight, I am not sure if people realize how immense the size of programmers willing to use this in 2.0 (was 1.1). Flash should stay competitive but so should coders, the move from AS2 to AS3 is taking too long. Silverlight 2.0 is fun and it is a force to be reckoned with. Don’t limit yourself to one platform, use both to your advantage.

    Tuesday, December 25, 2007 at 2:36 am #
  22. wrote:

    Un peu mon neveu, je veux !!!
    Excuses me i can’t give a good traduction …
    Happy new year Thibault and please Adobe, make this gift to our friend …

    Tuesday, December 25, 2007 at 6:09 pm #
  23. NateJC wrote:

    You definitely get my vote! The FileReference API has troubled me for quite some time.

    Wednesday, December 26, 2007 at 7:06 am #
  24. Pleh wrote:

    This is the main feature that is missing from the current version of flash player, now that Silverlight has allowed this feature, Adobe better follow suit, or many developers will be forced to switch over to silverlight.


    Wednesday, December 26, 2007 at 7:31 pm #
  25. I agree with you.
    I think it is not difficult for Adobe to add the File IO thing, because AIR already had it. I understand Adobe concerns about the security issuses. But they have to make a decision for it this time.

    Friday, December 28, 2007 at 9:23 am #
  26. Andrew Traviss wrote:

    As developers, this feature is very attractive to us; it would certainly open some doors and make life easier.

    However, I don’t think that it is actually a positive feature for privacy/security-conscious users. Just having the feature in the player would drive them away from the product. There’s no effective way I can think of to reduce the risk of this feature without gimping it beyond use.

    I’m pretty sure that Adobe’s response to any petition like this will be “Deploy on AIR if you want desktop application functionality”. In fact my response to this is “Deploy on AIR if you want desktop application functionality”.

    Friday, December 28, 2007 at 8:04 pm #
  27. Kenny Bunch wrote:

    Add my vote. It’s a thorn in my side

    Saturday, December 29, 2007 at 5:50 am #
  28. Cato wrote:

    Add my vote. I agree with you.

    Tuesday, January 1, 2008 at 7:47 pm #
  29. Philippe Vignau wrote:

    I’m in !

    Wednesday, January 2, 2008 at 1:49 pm #
  30. I totally agree, and add BitmapData in list.

    Wednesday, January 2, 2008 at 8:21 pm #
  31. taisen wrote:

    add my vote!

    Wednesday, January 2, 2008 at 9:37 pm #
  32. LAlex wrote:

    Andrew> Another answer could be “Develop on Silverlight if you want this feature”…

    I just want to stay on the Flash plateform to use this kind of functionality, and as Thibault said, as this could be used only after selecting a file (or a save location), I don’t think there would be any security issue…

    All that to say that I give my vote too! ;o)

    Thursday, January 3, 2008 at 1:01 pm #
  33. john b wrote:

    It really shouldn’t be a security issue considering once the user selects the file you can upload to your server right away anyways, what’s the diffrence with that and having instant access without requiring the upload?

    Thursday, January 3, 2008 at 11:25 pm #
  34. pigiuz wrote:

    thumb up!
    It would be very useful if a user can access to his local file from flash player (something like a preview of the selected file before the upload..)

    add my vote

    Saturday, January 5, 2008 at 2:35 am #
  35. judah wrote:

    Here’s how it works guys. If you want this you have to vote for it.

    Thibault, submit a bug describing this feature and post a link for us to vote for it. When it hits a threshold things happen.

    Tuesday, January 8, 2008 at 6:30 am #
  36. Cato wrote:

    I have submited it as a Feature Request. Follow the link and create a accont and vote for it!

    Tuesday, January 8, 2008 at 9:49 pm #
  37. Thibault Imbert wrote:

    Hi Cato,

    excellent, thank you !

    Tuesday, January 8, 2008 at 9:52 pm #
  38. falken80 wrote:

    Yeah i want to do that !
    But i want too that they implement an real exec function with arguments !
    ( only for executable flash windows, apple , linux… )

    Wednesday, January 9, 2008 at 5:01 pm #
  39. joeflash wrote:

    I second that.

    I suspect the reason Adobe is not making this easy is because of pressure from the IT sector to “improve security,” (including DRM), and it must be a hard line to walk between openness and security — but I do hope Adobe doesn’t continue sacrificing developer usability in the process.

    Monday, January 14, 2008 at 6:53 am #
  40. Beej wrote:

    There’s another request here which has been forwarded and closed:

    Thursday, January 17, 2008 at 1:57 am #
  41. Thibault Imbert wrote:


    Thanks Beej

    Thursday, January 17, 2008 at 2:00 am #
  42. +1

    Since the file can be selected only via a File Selection box, ( which the user does manually) Security won’t be compromised, I guess.

    AbdulQabiz just posted a feature request for more HTTP API support, in the same fashion :

    Sunday, January 20, 2008 at 7:16 am #
  43. efish wrote:

    Yes, i agree, add my vote.
    With this feature, net bandwidth wasting can be reduced.

    Monday, January 21, 2008 at 6:22 am #
  44. boblemarin wrote:

    +1 !

    Monday, January 21, 2008 at 8:13 pm #
  45. JAD wrote:

    This would be huge if Adobe did this. I can’t imagine the process offload on servers if this happened. You have my vote too!

    Tuesday, January 22, 2008 at 4:51 pm #
  46. jim wrote:


    Wednesday, January 23, 2008 at 2:50 pm #
  47. Hasan wrote:

    This would definitely be a game changer in a lot of ways!!


    Friday, January 25, 2008 at 9:47 pm #
  48. NewMan wrote:

    i need it

    Friday, February 1, 2008 at 1:34 pm #
  49. yoy wrote:

    if you love it, vote for it
    FileReference API

    Monday, February 4, 2008 at 10:11 pm #
  50. Rafagd wrote:

    Agree… I miss this features on forms with images…

    Since i can’t open the file, i can’t send the file via remoting…

    That’s pretty lame…

    Friday, February 15, 2008 at 3:36 pm #
  51. Vijay Chakravarthy wrote:

    I was faced with a similar problem, and looked around and found this post. Which also got me thinking — wouldnt it be possible (in cases where someone has both silverlight and flash 9 installed) to do this via silverlight to flex communication via the browser?

    Sunday, February 24, 2008 at 9:15 pm #
  52. Jensa wrote:

    Yeah. Good point!

    (and congrats on the new job!)


    Saturday, March 8, 2008 at 12:25 am #
  53. +1 here as well!
    Our Adobe flash apps would help us grow with a feature like this.

    Thursday, March 13, 2008 at 3:59 am #
  54. collin wrote:

    +2 here (my partner wants this BADDD)

    Saturday, March 15, 2008 at 12:12 pm #
  55. CantGetRight wrote:

    This has my vote!

    Regarding the security… I don’t see how this could be a problem. Whenever a user saves a file, he/she is at risk of downloading something corrupt. Be it downloaded or straight from the player.

    Saturday, April 12, 2008 at 4:50 pm #
  56. Rogier wrote:


    I can see why Adobe currently doesn’t allow local files to be accessed at all, but it should at least be a security setting.
    This way we can ask a user for permission (allow/always allow), similar to access of the camera/microphone.

    Also, I think it should not only be limited to the FileReference; I’ve been experimenting with drag & drop uploads using a combination of javascript and Flash, I managed to find a way to detect an image drop on the browser using javascript and I seriously would like to be able to tell Flash to load this particular image so I can manipulate it (resize, crop, rotate) it _before_ I upload it from a ByteArray.

    Thursday, May 22, 2008 at 8:28 am #
  57. Thibault Imbert wrote:

    Hi Rogier,

    it seems like Adobe listened to this request. Such a feature is available in Astro (Flash Player 10)

    Check this post :)

    Saturday, May 24, 2008 at 4:52 am #

Trackbacks/Pingbacks (2)

  1. [...] in the NetStream class you have to send it to a server and load it again, damn, do you remember a similar story [...]

  2. [...] on guys ! We raised our voice for FileReference, if you would be happy having such a feature, vote for it ! Post a comment | Trackback [...]