我很难理解我应该在我正在处理的代码中的何处实现wrapAsync/bindEnvironment。我正在使用 http/knox 调用 url 并将其上传到我的 S3 存储桶,该存储桶可以正常工作,但是当我尝试在回调中调用该函数时,我遇到了 Meteor code must always run inside a Fiber
。
我尝试将回调包装在bindEnvironment中并尝试使用wrapAsync,但一定没有完全理解它是如何工作的。任何指导将不胜感激!
http.get(imageUrl, function(res) {
let headers = {
'Content-Length': res.headers['content-length']
, 'Content-Type': res.headers['content-type']
};
S3.knox.putStream(res, `/${imageName}`, headers, function(err, res) {
if (err) {
log.error(`(imageUpload): Error uploading image with knox: ${err}`);
} else {
let amazonImagePath = `https://s3.amazonaws.com/${bucketName}/${imageName}`;
// TODO Figure out why fiber issue is happening with expenseInsert in callback
expenseInsert(expenseObj, amazonImagePath);
}
});
});
最佳答案
试试这个:
S3.knox.putStream(res, `/${imageName}`, headers, Meteor.bindEnvironment(function(err, res) {
//rest of the code
}));
关于javascript - Meteor Fiber 在诺克斯中出现回调问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39898238/