我在差异位置 1.Upload1.abc.com 2.upload2.abc.com 有多个保管库。如果文件上传失败,我想在 Upload1.abc.com 上发帖,它将重新开始整个过程以将文件发布到 Upload2.abc.com
这样文件上传就不会失败。即使一个块再次失败,整个集合也会在运行时上传到下一个后备 url。
我在差异位置 1.Upload1.abc.com 2.upload2.abc.com 有多个保管库。如果文件上传失败,我想在 Upload1.abc.com 上发帖,它将重新开始整个过程以将文件发布到 Upload2.abc.com
这样文件上传就不会失败。即使一个块再次失败,整个集合也会在运行时上传到下一个后备 url。
这无疑是一种处理失败上传的有趣方式。有没有办法保证1.Upload1.abc.com永远向上?
我会对completeFine Uploader 抛出的事件做出反应。如果responseJSON有一个不是success的属性,则弹出端点堆栈的新端点,发出调用,最后发出调用,以便上传重新开始,如下所示, truesetEndpointretry
var original_endpoints = ['1.Upload1.abc.com', '2.upload2.abc.com']
, endpoints = original_endpoints;
var fu = new qq.FineUploader({
// ... Other options
cors: {
expected: true // this *must* be a cross-origin request
},
request: {
endpoint: endpoints.shift() // the original endpoint to be attempted first
},
callbacks: {
onComplete: function (fileId, fileName, responseJSON, xhr) {
if (responseJSON.success != true) {
var endpoint = endpoints.shift();
if (endpoint !== undefined) {
// Changes endpoint for *all* subsequent uploads
this.setEndpoint(endpoint);
// Or, to change the endpoint for this particular file that failed
// and try the original endpoint again on the next file,
// this.setEndpoint(endpoints, fileId);
} else {
// This will restart the process by setting the endpoints queue to
// its default. Note that you may want to handle the error of all
// endpoints failing another way, as this just restarts the process
// and may result in an infinite loop if all endpoints are constantly down.
endpoints = original_endpoints;
this.setEndpoint(endpoints.shift());
}
this.retry(fileId); // Retry the upload
}
}
}
});