Comments (8)
并发保存的问题。在 LC 的 iOS 客户端也碰到了这个问题。
from leantodo-weapp.
tempObjects 是什么?文件还是对象?
看起来你想批量保存一批对象,然后其中一个失败了(Document not found),整个 Promise 就失败了。
这是符合预期的啊,你需要 debug 下哪个对象是不存在的。
另外,AV.Object.saveAll 可以用在一个请求里批量保存对象,会更可靠(但是在这个 case 里肯定还是会 Document not found 失败)。
另外,你确定这个问题是 leantodo-weapp 的问题?
from leantodo-weapp.
是一个文件。其实我的源码是类似这样的:
function saveAll(tempFilePaths) {
var promises = [];
for (var i = 0; i < tempFilePaths.length; i++) {
promises.push(savePhoto(tempFilePaths[i]));
}
return AV.Promise.all(promises);
}
function savePhoto(tempFilePath) {
var photo = new Photo();
photo.set('photoFile', new AV.File('wxapp', {
blob: {
uri: tempFilePath
},
}));
return photo.save();
}
然后,调用方式是这样的:
saveAll(tempFilePaths).then(null, function(err){
// 错误处理
}).then(function(){
// 不管成功失败,都刷新一下
refresh();
});
因为这个 refresh() 始终没有被调用,所以才说是可能没有超时的处理。
from leantodo-weapp.
然后我把 saveAll 去掉了,改成 reduce 的方式,强制改成顺序上传是可行的:
tempFilePaths.reduce(function(promise, tempFilePath) {
return promise.then(function() {
return savePhoto(tempFilePath);
});
}, AV.Promise.resolve(true)).catch(function(err) {
// 错误处理
}).then(function() {
// 不管成功失败,都刷新一下
refresh();
})
from leantodo-weapp.
如果是并发上传的话,小程序有个同事 5 个请求的上线,可以看下控制台有没有类似的异常。我不确定这个异常是否会被正确 catch 到,我需要试一下。
from leantodo-weapp.
OK,我这边是选择了两张图片同时做上传出现的。是在移动端出现,但是在小程序的那个 IDE 里面没有。
而且没有发现类似的异常,我的移动端是能一直重现的,改成 reduce 的时候倒是一切正常了。
from leantodo-weapp.
论坛也有类似的多图上传失败的报告,我调查一下:
https://forum.leancloud.cn/t/topic/12790
from leantodo-weapp.
Android 真机不支持并发上传图片。详情与解决方案参见上面的论坛帖子。
from leantodo-weapp.
Related Issues (15)
- Android 对云代码的调用有问题? HOT 3
- 为什么在微信开发者工具里面 HOT 6
- 似乎不支持wepy? HOT 1
- READEME 里面可以提示一下,运行 Dmeo 需要配置域名白名单。
- 有退款的demo和企业付款到零钱的demo么?
- typo error HOT 3
- 一个潜在的兼容性Bug HOT 2
- 放到本地无法进入到小程序页面 HOT 2
- 修改后的 leancloud-storage.js 文件,一直报 Could not find user HOT 9
- 合法域名校验出错 我按照文档照做了 HOT 1
- 用了 av-weapp-min.js 后出现以下错误 HOT 1
- 显示401,unauthorized错误 HOT 1
- 微信错误,errcode: 40029 HOT 1
- wx.previewImage无法预览AV.File生成的图片 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leantodo-weapp.