[英]Meteor Fiber issue with callback in knox
我在理解我應該在我正在處理的代碼中究竟應在哪里實現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);
}
});
});
嘗試這個:
S3.knox.putStream(res, `/${imageName}`, headers, Meteor.bindEnvironment(function(err, res) {
//rest of the code
}));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.