views:

94

answers:

1

I am using Ruby, RestfulX, and Paperclip to upload a File, using the FileReference class.

I get the response from Paperclip in the terminal that says I've successfully saved the file, but it appears Flash never gets what it needs to know the upload has been successful.

I'm getting this error if I try to upload again while the CursorManager's 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 that I need to tell Flex that I've successfully saved the file. Is there a way to manually do that? Do I need to pass a session or cookie or anything?

+2  A: 

In my web services (PHP/Python) I send a response via the service. The upload occurs, is processed and a return is sent that Flex/FLash event handler uses as a response. If there is no return on the service side, Flex/Flash will not know that anything as happened, and as such the event handler will not be activated. Generally this can be as simple as a return True statement, or something more complex depending on your needs.

So FileReference generally dispatches an Event.COMPLETE when it is finished. I am guessing that this is what handles the mechanisms internally. I wonder if the DataEvent is somehow going around that mechanism? You could manually dispatch the Event.COMPLETE from the FileReference in your handler.

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

not the prettiest of solutions, but I'd be curious if it worked.

Joel Hooks
I am getting the response back, but it still hasn't given flash something it wants so the "fileReference.upload()" call is resolved... My handler for "DataEvent.UPLOAD_COMPLETE_DATA" is called when rails sends a response, but it's still not resolved... any ideas?
viatropos
added some additional thoughts.
Joel Hooks
worked! thanks Joel, I appreciate it. I think you're right about DataEvent.
viatropos
I think RestfulX should handle this. If it doesn't, they should fix it ;)
Joel Hooks