我很难理解在我正在处理的代码中应该在哪里实现 wrapAsync/bindEnvironment。我正在使用 http/knox 调用一个 url 并将其上传到我的 S3 存储桶,它可以工作,但是当我尝试在回调中调用该函数时,我遇到了Meteor code must always run within 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);
}
});
});