YUI uploader error handling

138 views Asked by At

This specifically regarding the errorAction:Y.Uploader.Queue.RESTART_AFTER. Sorry if I'm reposting this question I searched but I could not find anything relevant.

I'm using YUI uploader for one of my projects my question is about error handling.

uploader = new Y.Uploader({
                width: "72px",
                height: "20px",
                multipleFiles: true,
                swfURL: "YUI_3.18/uploader/assets/flashuploader.swf?t=" + Math.random(),                
                uploadURL: "http://xxxxxx.cloudfront.net/",
                fileFieldName: 'file',
                selectFilesButton: Y.Node.create(buttonSkin),
                simLimit: simUploadLimit,
                errorAction:Y.Uploader.Queue.RESTART_AFTER
            });    

I want to know how to test if 'errorAction:Y.Uploader.Queue.RESTART_AFTER' this is really happening. Eg: an upload fails and get re added to the queue.

Also I want to know how to simulate a failed upload (if it is possible).

Thanks you very much for your help.

2

There are 2 answers

0
Diptendu On BEST ANSWER

Assuming simUploadLimit is more than 1 your uploader supports multiple simultaneous file uploads. You can test errorAction:Y.Uploader.Queue.RESTART_AFTER using the following steps

  1. Selected 2 X simUploadLimit number of files for upload
  2. Move one of the files to a diff directory when the upload is in progress

That particular file upload will fail but others will go through. Uploader will try this file again after rest of the files are uploaded successfully.

0
Arun On
Fail for every request to test this scenerio. Hack :)



 if("your file name".equalsIgnoreCase(fileName)){
            response.setProperty(ResourceResponse.HTTP_STATUS_CODE,
                    Integer.toString(HttpServletResponse.SC_BAD_REQUEST));
            return;
        }

This will always fail and automatic message queue puts current file to retry it after all other files are complete.