代码之家  ›  专栏  ›  技术社区  ›  user1832464

FineUploader分块上传无法继续

  •  0
  • user1832464  · 技术社区  · 10 年前

    我有以下手动激活上传器的实例:

    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();
    });
    

    我指定了一个块文件夹,我可以看到块已上载。文件上载过程正常完成。

    但是,在取消或意外终止的情况下,上载不会继续。块仍然存在于目录中,所有标准浏览器cookie都已启用,但恢复不会发生。

    分块调试输出如下。我上传了几个块,取消并重新尝试上传:

    [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 
    

    知道为什么会这样吗?

    我还有一个与问题无关的问题。对于onComplete回调,我只想启动submitForm.call(this)函数(它提交表单)。但是,如果我只指定 onComplete: submitForm.call(this) 因为抛出错误,表示未定义onComplete响应。。。

    为赛格威道歉,再次感谢。

    1 回复  |  直到 10 年前
        1
  •  0
  •   Ray Nicholus    10 年前

    已取消的文件不符合恢复条件。此外,从5.0开始,cookie不再用于保存简历数据:我们使用 localStorage 相反日志消息表明文件已取消,这意味着无法恢复。

    onComplete回调需要一个函数作为值。相反,您正在调用一个函数,并将该函数的返回值设置为 onComplete 听起来像是对什么的误解 Function.prototype.call 在JavaScript中执行。 call 执行函数。如果要构造具有备用上下文的新函数,请使用 Function.prototype.bind 相反请注意 bind IE8及更早版本不支持。如果您需要支持IE8或更高版本,可以使用 Fine Uploader's bind alternative: qq.bind .