作業中のコードで 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);
}
});
});