Question

I have the following instantiation for a manually-activated uploader:

var manualuploader = new qq.FineUploader({
    element: $('#jquery-wrapped-fine-uploader')[0],
    request: {
        endpoint: '/data/assets/ajax/uploader.php'
    },
    autoUpload: false,
    text: {
        uploadButton: '<i class="icon-plus icon-white"></i> Select Files to upload'
    },
    chunking: {
        enabled: true,
        partSize: 50000000
    },
    resume: {
        enabled: true
    },
    debug: true,
    callbacks: {
        onComplete: function (id, fileName, response) {
            $('#uploader').append('<input type="hidden" name="fileasdf[]" value="' + response.originalName + '" />');
            submitForm.call(this);
        },
        onError: function (event, id, name, errorReason, xhrOrXdr) {
            alert(qq.format("Error on file number {} - {}.  Reason: {}", id, name, errorReason));
        }
    }
    });
    $('#triggerUpload').click(function() {      
    manualuploader.uploadStoredFiles();
});

I have a chunk folder specified, and I can see the chunks are uploaded. The file upload process completes normally.

However in the event of a cancel or unexpected termination, the upload does not resume. The chunks still exist in the directory, all standard browser cookies are enabled, but the resume doesn't happen.

Chunking debug output is as follows. I upload a couple of chunks, cancel, and reattempt the upload:

[Fine Uploader 4.4.0] Sending chunked upload request for item 1: bytes 1-50000000 of 346011648 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] xhr - server response received for 1 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] responseText = {"success":true,"uploadName":null} fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Received response status 200 with body: {"success":true,"uploadName":null} fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Sending chunked upload request for item 1: bytes 50000001-100000000 of 346011648 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] xhr - server response received for 1 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] responseText = {"success":true,"uploadName":null} fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Received response status 200 with body: {"success":true,"uploadName":null} fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Sending chunked upload request for item 1: bytes 100000001-150000000 of 346011648 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Detected valid file button click event on file 'CentOS-6.3-x86_64-minimal.iso', ID: 1. fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Cancelling 1 fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Caught exception in 'onError' callback - Cannot read property 'length' of undefined fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Received 1 files or inputs. fineuploader-4.4.0.min.js:25
[Fine Uploader 4.4.0] Sending chunked upload request for item 2: bytes 1-50000000 of 346011648 

Any idea why this is the case?

I also have another query unrelated to the question. For the onComplete callback, I only want to fire the submitForm.call(this) function (which submits the form). however if I if only specify onComplete: submitForm.call(this) as error is thrown saying that the onComplete response is not defined...

Apologies for the segway, and thanks again.

Was it helpful?

Solution

A cancelled file is not eligible for resume. Also, as of 5.0, cookies are no longer used to persist resume data: we use localStorage instead. Your log messages indicate that the file was cancelled, which means it cannot be resumed.

The onComplete callback expects a function as a value. Instead, you are invoking a function and setting the return value of that function as the value of onComplete. It sounds like a misunderstanding of what Function.prototype.call does in JavaScript. call executes a function. If you want to construct a new function with an alternate context, use Function.prototype.bind instead. Note that bind is not supported in IE8 and older. If you need to support IE8 or older, you can use Fine Uploader's bind alternative: qq.bind.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top