2016-10-06 3 views
0

정확하게 작업하고있는 코드에서 wrapAsync/bindEnvironment를 구현해야하는 위치를 이해하는 데 어려움이 있습니다. http/knox URL로 전화를 걸고 작동하는 S3 버킷에 업로드하고 있지만 콜백에서 함수를 호출하려고하면 Meteor code must always run within a Fiber이 표시됩니다.Meteor Fiber 문제가 knox에서 콜백 사용

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); 
    } 
    }); 
}); 

답변

1

이 시도 :

S3.knox.putStream(res, `/${imageName}`, headers, Meteor.bindEnvironment(function(err, res) { 
    //rest of the code  
}));