1 (edited by Leonard 2010-09-18 01:59:24)

Topic: How to stop chunked upload?

Hey guys,

I've gotten chunk uploading working and it's all nice and good but I'm having some trouble with getting it to STOP uploading the remaining chunks if a chunk fails to upload.

Here's my callback:

    //When each chunk is uploaded, check if there were any errors or not
    uploader.bind('ChunkUploaded', function(up, file, response){
        var responseObj = jQuery.parseJSON(response.response);
        $('#filelist').append('<br />' + responseObj.status);

        if (responseObj.status == "fail"){

            $('#' + file.id + " b").html("Error! " + responseObj.error.message);

            console.log('WTH!');
            //Stop the upload!
            up.stop();
//I've also tried uploader.stop()
        }

    });


Despite calling the stop method, plupload continues to send the remaining chunks up.

Btw I have a custom JSON response var 'status'. In my debugging the above code is definitely going into the fail loop and should stop all remaining chunks from uploading.

Anyone solve this problem?

Thanks,

Leonad

Re: How to stop chunked upload?

We used to have a automatic stop of uploading of chunks. However this function was removed a few versions back since parts of the API was rewritten. We will however reintroduce it since it makes no sense to upload all chunks if an error occurs.

Re: How to stop chunked upload?

Maybe this will help you:

    uploader.bind('FileUploaded', function(up, file, res) {
        switch(up.state){
            case plupload.STOPPED:
                someCancelHandler();
            break;
        }
        ...
    }