fine-uploader 如何从分块成功中得到响应?
fine-uploader how to get the response from chunking success?
如何获得分块成功的响应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);
}
}
})
我想你对各种回调有点困惑。 onUploadChunkSuccess
、as the documentation states, will be called for each chunk after the chunk has successfully uploaded. But according to your code, you are not looking for this. Instead, you want Fine Uploader to call a specific endpoint once all chunks have been uploaded, and then you require access to the response to that request in a callback. The documentation page for the concurrent chunking feature(您已启用)说明如何获取对此请求的响应:
Expected response for the chunking success POST
For successful responses, you may return an empty body with a status
of 200-204. Any other status code is determined to be a failure. You
can also return a JSON response with any data your would like passed
to your onComplete handler. Furthermore, you can include an error
property in your response with the error message you would like to
have displayed next to the failed file (if you are using Fine Uploader
UI).
如何获得分块成功的响应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);
}
}
})
我想你对各种回调有点困惑。 onUploadChunkSuccess
、as the documentation states, will be called for each chunk after the chunk has successfully uploaded. But according to your code, you are not looking for this. Instead, you want Fine Uploader to call a specific endpoint once all chunks have been uploaded, and then you require access to the response to that request in a callback. The documentation page for the concurrent chunking feature(您已启用)说明如何获取对此请求的响应:
Expected response for the chunking success POST
For successful responses, you may return an empty body with a status of 200-204. Any other status code is determined to be a failure. You can also return a JSON response with any data your would like passed to your onComplete handler. Furthermore, you can include an error property in your response with the error message you would like to have displayed next to the failed file (if you are using Fine Uploader UI).