سؤال

I want to download a file in flex. Here is my desired flow

  • User clicks "view"
  • Code goes to backend and get the file as an array of bytes
  • bytes sent from java to flex via a callback
  • flex then opens dialog and user decides where to save the file

Unfortunately the last part is not on a user event but on the callback from the server. When I call new FileReference().save(...) it tells me this.

An alternative could be

  • User clicks "view"
  • Flex shows user the dialog and user chooses where to save file
  • Flex goes to backend requesting bytes of file
  • bytes sent to flex and data is saved.

For this approach I am unsure how I can make the save asynchronous from the dialog.

Does anyone have any ideas on how I can approach this? Basically I want the user to save a file but the data but come from an array of bytes from the backend

Thanks

هل كانت مفيدة؟

المحلول

FileReference.save() method is not used when you want to save the result.. this method is called only when the mouse or keyboard event occurs. so my advice to you that don't use this method. You can use that method in other way like save the file using JAVA in on back end side. and the method will return you the path of that. you just need to create a URLRequest and call the navigateToURL method. as i have given below.

var path:String = e.result.toString();
var urlRequest:URLRequest = new URLRequest(path);
navigateToURL(urlRequest,"_blank");

Have a Nice Day....

نصائح أخرى

How can I download a file from an FTP site (not HHTP). I can't use URLRequest for that. I found some infos about using the socket, but all of them are for UPLOADING. I need to DOWNLOAD

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top