views:

17

answers:

0

This is a bit of an premature post, because I'm still grokking the code. But I've looked for a day, and I suspect it's something simple I'm missing about the Actionscript environment.

Goal:

I have Uploadify uploading to the Rails server. When the file gets uploaded to the server, it gets renamed. I want to respond with the new filepath, so the user can immediately delete the file without a page reload.

Problem:

Uploadify only works if I use: render :text => "1". When I change it to: render :text => uploaded_file.filename, the uploadifyComplete action is never triggered. Instead, an uploadifyError is thrown, with an HTTPError.

My Diagnosis:

Flash is dispatching an HTTPError, but I can't figure out how or why it decides that my response is an HTTPError. I tried: render :text => "1", :status=>200, but that fails with an HTTPError as well.

My Question Stack

  • Basically, how should I achieve this functionality?
  • => Why does Uploadify trigger an HTTP Error?
  • ===> Why does the Actionscript trigger an HTTP Error?
  • =======> If you know who decides (or where it is decided) that I have an HTTP Error, where is it?

Code:

// Upload each file
function uploadFile(file:FileReference, index:int, ID:String, single:Boolean):void {
    var startTimer:Number      = 0;
    var lastBytesLoaded:Number = 0;
    var kbsAvg:Number          = 0;

    // ... Code removed for brevity

    // Handle all the errors    
    file.addEventListener(HTTPStatusEvent.HTTP_STATUS, function(event:HTTPStatusEvent):void {
        if (errorArray.indexOf(ID) == -1) {  
            $trigger('uploadifyError',ID,event.currentTarget,{
                'type' : 'HTTP',
                'info' : event.status
            });
            finishErrorHandler(ID);
        }
    });
}