2017-02-10 108 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)。