1
有任何一个你想上传50+图像cloundinary?我一直在尝试,但问题在于承诺没有得到解决(即使使用.reflect()也无法上传所有图像。根据上传速度,它将失败30%〜70%。cloudinary多种JPG格式上传的Node.js
有没有方法彻底让它异步,并确保所有图像都正确上传?只有我使用的是从他们的文档的蓝鸟和cloudinary模块模块。
Promisebd = require('bluebird');
function uploadimg(img, i, itemId) {
var pubID = 'a2z/toys/' + itemId + '/' + i;
// return new cloudImg.v2.uploader.upload(img, {
return cloudinary.v2.uploader.upload(img, { // works
public_id: pubID,
quality: 90
// use_filename: true,
} , function(err, res){
if(err) {
console.log(err);
}
console.log(res);
});
}
promiseArr.push(uploadimg(fullimg, i, d[0].details.detailsProductId)); // pushing the promises to Arr
Promisebd.all(promiseArr.map(function(promise) {
return promise.reflect();
})).each(function(inspection) {
if(inspection.isFulfilled()) {
console.log('The promise is the arr was fulfilled with ', inspection.value());
}else{
console.log('The promise is NOT the arr was NOT fulfilled with ', inspection.reason());
}
})