API를 통해 파일을 다운로드하기 위해 Meteor 서버에서 요청을 보내고 있습니다. 그런 다음 해당 파일을 S3에 업로드하고 싶습니다. 다음 "NoSuchKey : 지정된 키가 없습니다."라는 메시지가 계속 나타납니다 . 처음에는 AcessKey / SecretKey 양식 AWS에 문제가 있다고 생각했지만 잠시 동안 인터넷 검색을 한 후 다른 사람들이 S3에서 파일을 다운로드하려고 할 때이 오류가 발생하는 유일한 예를 찾을 수있었습니다.
cfs : s3 설정
var imageStore = new FS.Store.S3("images", {
accessKeyId: "MyAcessKeyId", //required if environment variables are not set
secretAccessKey: "MySecretAcessKey", //required if environment variables are not set
bucket: "BucketName", //required
});
Images = new FS.Collection("images", {
stores: [imageStore]
});
API에서 파일 전송을 시작하고 S3에 업로드
client.get_result(id, Meteor.bindEnvironment(function(err, result){ //result is the download stream and id specifies which file to download.
if (err !== null){
return;
}
var file = new FS.File(result);
Images.insert(file, function (err, fileObj) {
if (err){
console.log(err);
}
});
}));
참고 : 다음 오류가 발생하여 Meteor.bindEnvironment를 추가했습니다. "Meteor 코드는 항상 Fiber 내에서 실행되어야합니다. Meteor.bindEnvironment를 사용하여 Meteor가 아닌 라이브러리로 전달하는 콜백을 래핑하십시오."
API 문서의 Node.js 예제
client.get_result(id, function(err, result){
if (err != null) {
return;
}
file.writeFile(path.join('public', path.join('results', filename)), result, 'binary');
});
나를 위해 문제를 해결하게 된 것은 설정의 일부를 lib 폴더로 이동하는 것이 었습니다. 여러 가지 방법을 시도했지만 서버에서 완전히 실행할 수 없었습니다. 모든 것을 좀 더 명확하게 설명하는 문서가 최근에 업데이트 된 것 같습니다. 이 설정을 따르면 오류가 제거됩니다. 클라이언트, 서버 및 S3 자격 증명 섹션을 참조하십시오.
https://github.com/CollectionFS/Meteor-CollectionFS/tree/master/packages/s3
참고 : 클라이언트에서 액세스 할 수있는 lib 폴더에 비밀 키를 두지 마십시오.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다