2017-02-10 48 views
0

我如何得到chunking成功url的响应:罚款上传如何获得分块成功的回应?

我可以看到它在控制台使用调试的响应,但我不能用回调得到它。

这里是我的代码:

// Some options to pass to the uploader are discussed on the next page 
var uploader = new qq.FineUploader({ 
    element: document.getElementById("uploader"), 
    debug: true, 
    retry: { 
     enableAuto: false, // defaults to false 
     showButton:true 
    }, 
    request: { 
     endpoint: '{{ hls_video_upload_form.action }}', 
     params: { 
      // user_kind: '{{ hls_video_upload_form.user_kind }}', 
      // user_ref: '{{ hls_video_upload_form.user_ref }}' 
      user_ref: $("input[name=user_ref]").val(), // USER_REF from Form 
      user_kind: $("input[name=user_kind]").val() // USER_KIND from Form 
     } 
    }, 
    chunking: { 
     enabled: true, 
     mandatory: true, 
     concurrent: { 
      enabled: true 
     }, 
     success: { 
      endpoint: '/onCOMPLETE_UPLOAD' 
      // I WANT THE RESPONSE OF THESE 

     } 
    }, 
    callbacks: { 
     onComplete: function(id, fileName, response, xhr) { 
      console.log(response); 

     }, 
     onUploadChunkSuccess : function(id, chunkData, response, xhr) { 
      console.log(response); 

     } 

    } 
}) 

回答

0

我觉得你是一个有点困惑的各种回调。 onUploadChunkSuccess,as the documentation states,将在块成功上传后调用每个块。但根据你的代码,你不是在寻找这个。相反,您希望Fine Uploader在所有块上传完成后调用特定的端点,然后您需要在回调中访问对该请求的响应。 The documentation page for the concurrent chunking feature(你已经启用)说明如何获得这一请求的响应:

期望的回应为分块成功POST

对于成功响应,你可能会返回一个空的身体与状态 200-204。任何其他状态代码被确定为失败。您还可以使用您想要将 传递给您的onComplete处理程序的任何数据返回JSON响应。此外,您可以在回复中包含错误 属性,并显示您希望 显示在失败文件旁边的错误消息(如果您使用Fine Uploader UI)。