How does Flash Player know when you successfully downloaded a file?

I use Ruby, RestfulX, and Paperclip to upload a file using the FileReference class.

I get a response from Paperclip in the terminal that says I successfully saved the file, but it seems like Flash never gets what it needs to know that the download was successful.

I get this error if I try to load again when the CursorManager clock is spinning:

Error: Error # 2174: Only one download, upload, load or save operation can be active at a time on each FileReference.

It seems I need to tell Flex that I successfully saved the file. Is there any way to do this manually? Do I need to go through a session or cookie or something else?

+3
source share
3 answers

In my web services (PHP / Python) I submit the response through the service. The download occurs, is processed and a return is sent, which the Flex / FLash event handler uses as a response. If there is no return on the service side, Flex / Flash will not know anything that happened, and therefore the event handler will not be activated. This can usually be as simple as an operator return True, or something more complex, depending on your needs.

So FileReference usually dispatches Event.COMPLETE upon completion. I guess this is what handles mechanisms domestically. I wonder how the DataEvent somehow circumvents this mechanism? You can manually send Event.COMPLETE from FileReference in the handler.

fileReference.dispatchEvent(new Event(Event.COMPLETE));

, , .

+2

: FileReference.cancel();

, (, ) :

var url : String = fileReference.url;
fileReference.cancel();
fileReference = new File(url);

:   FileReference.upload()

0

Before calling the viewer, you must call fileReference.cancel (). This resets the fileReference before each view call.

fileReference.cancel();
fileReference.browse( [new FileFilter( "Excel", "*.xls;*.xlsx" )] );
0
source

Source: https://habr.com/ru/post/1723705/


All Articles