R – Flex 3 – Send a HTTP Get request from Flash and want Firefox to show Open With Box

firefoxflex3http

I am a newb developer as far as Flex and Flash is concerned. This is what I'm trying to do:

1) Send a HTTP request to our server (with a custom made URL). The URL basically tells the server to send data in a CSV format.
2) The server sends a 200 OK response, which has Content-Type: application/csv and the payload is pure CSV data.

What I wish to do is, when firefox gets this 200 OK response, I want it to show the standard Open with box (the one that shows up when you download some file).

I tried doing this with HTTPService. I have a "Export to CSV" button on the flash component. Upon clicking that, the flash component is able to succesfully send the HTTP request. I however don't want Flash component to handle the response, so I don't have the 's "result" tag defined. But nothing happens. Any suggestions on how to do this.

Best Answer

You will need Flash to at least respond to the request, then you call navigateToURL to go to your file, something like this:

private function resultHandler(event:ResultEvent):void
{
    navigateToURL(new URLRequest('createdFile.csv','_self'));
}