在我的應用程序中,當chunking-success-endpoint返回JSON如{"error": "reason..."}
(例如服務器無法將塊重新組合在一起)時,onError
事件不存在調用。如何在Fine-uploader中引發組塊成功終結點上的onError
只是爲了澄清,onError
事件是如果個別塊失敗調用。這是我遇到的最終成功要求。
我不確定我錯過了什麼。我應該以其他方式處理這個問題嗎?
我的配置如下。提前致謝!
var uploader = $('#fine-uploader').fineUploader({
template: 'qq-template',
debug: true,
callbacks: {
onAllComplete: function(succeeded, failed) {
$('#doclib_tree').jstree(true).refresh()
if (failed.length > 0) {
alert("Error: Some files were not uploaded");
} else {
if (succeeded.length > 0) {
alert("Successfully uploaded " + succeeded.length + " file(s)");
}
this.reset();
toggle_upload();
}
},
onError: function(id, name, errorReason, xhrOrXdr) {
alert("Error uploading " + name + ". Reason: " + errorReason)
},
onSubmit: function(id, name) {
var promise = new qq.Promise();
var dest = document.getElementById('dest_label').innerHTML.replace(/ > /g, "/")
$.ajax({
'type': 'POST',
'async': false,
'url': "/documents/exists" ,
'data': {
'parents' : get_path(dest),
'name': name,
},
'success': function(data, textStatus, jqHXR) {
if (check_session(data)) {
promise.failure();
} else {
if (confirm("The file '" + dest + "/" + name + "' already exists. Replace?"))
promise.success();
else
promise.failure();
}
},
'error': function(jqHXR, textStatus, errorThrown) {
promise.success();
}
});
return promise;
},
},
chunking: {
enabled: true,
partSize: 20000000, // 20MB
success: {
endpoint: "documents/upload?success=1",
}
},
resume: {
enabled: true,
recordsExpireIn: 1, // 1 day
},
request: {
endpoint: "/documents/upload",
},
autoUpload: true
});
該文件實際上在UI中標記爲失敗,還是不工作? –
上傳被UI認爲是成功的。但是,如果chunking-success-endpoint返回502或無效的JSON,則onError事件_does_fire和文件被標記爲失敗。 –