I was wondering how to convert a file I have on my server (pdf/excel/ppt) to a ByteArray. The reason I want to do this is to display the dialogue open/save as to the user and I must set the Content-Type to octet-stream. The dialogue shows fine with just navigateToURL() but for pdf’s it is the user’s local browser setting. For a URLRequest I must set the data as a ByteArray. I’m trying to use the code located here:
Share
Provided you’re targeting Flash Player 10, this should work:
Assuming you load the file first — in this example, the load operation happens on creationComplete, and the bytes get stored off in loadedFile — the bytes should be and ready for saving when the user clicks Save Image. Tested and verified the example works. Hope it helps!