function onStateChanged(upload, status) {
if (upload.state == 4 && status == 200) {
// 上传完成
console.log("Upload success: " + JSON.stringify(upload));
plus.uploader.enumerate(function(t) {
console.log("还有"+t.length+"未上传")
})
}
}
我监听上传成功后,去枚举任务列表,全部都显示还没有上传
[LOG] : 一共有2张图片需要上传
[LOG] : Upload success: {"__UUID__":"uploader161457667916557","url":"http://192.168.1.33:8080/api/uploadfile/uploadPicture?table_name=t_baseinfo&row_id=32&file_name=全景-01-03-02-lazyload","state":4,"options":{"method":"POST"},"uploadedSize":0,"totalSize":1993,"responseText":"","method":"POST","timeout":120,"retry":3,"retryInterval":30,"priority":1,"onCompleted":null,"eventHandlers":{"statechanged":{"type":"statechanged","handles":[null],"capture":false}},"__requestHeaders__":{},"__responseHeaders__":{"Content-Type":"application/json; charset=utf-8","Content-Length":"157","Server":"beegoServer:1.6.0","Date":"Fri, 11 Mar 2016 03:45:14 GMT"},"__noParseResponseHeader__":null,"__cacheReponseHeaders__":{}}
[LOG] : 还有2未上传
[LOG] : Upload success: {"__UUID__":"uploader151457667916557","url":"http://192.168.1.33:8080/api/uploadfile/uploadPicture?table_name=t_baseinfo&row_id=32&file_name=全景-01-03-02","state":4,"options":{"method":"POST"},"uploadedSize":391189,"totalSize":391189,"responseText":"","method":"POST","timeout":120,"retry":3,"retryInterval":30,"priority":1,"onCompleted":null,"eventHandlers":{"statechanged":{"type":"statechanged","handles":[null],"capture":false}},"__requestHeaders__":{},"__responseHeaders__":{"Content-Type":"application/json; charset=utf-8","Content-Length":"148","Server":"beegoServer:1.6.0","Date":"Fri, 11 Mar 2016 03:45:14 GMT"},"__noParseResponseHeader__":null,"__cacheReponseHeaders__":{}}
[LOG] : 还有2未上传
levi (作者)
plus.uploader.enumerate 回调函数后面还有一个参数。文档说的,这个参数不填的话是默认返回还未上传成功的。但是他是把所有的上传任务都返回了。返回给我上传任务里面state应该都是不为4的吧。
2016-03-16 10:33