Firebase Cloud 기능이 도입됨에 따라 현재 node.js 서버 측 코드 중 일부가 클라우드 기능으로 옮겨 가고 있습니다. 내가 가지고있는 한가지 문제점은 GCS 버킷에서 디스크의 임시 파일로 파일을 다운로드 한 다음 첨부 파일 (mailgun-js 사용)로 전자 메일로 보내는 것입니다.firebase cloud function Google Cloud Storage의 API 오류
나에게 슬픔의 원인이 코드의 일부는 다음과 같습니다
는return mkdirp(tempLocalDir).then(() => {
const bucket = gcs.bucket(gcsBucket);
const tempFilePath = tempLocalDir + gcsFile;
return bucket.file(gcsFile).download({
destination: tempFilePath
}).then(() => {
console.log('File downloaded locally to', tempFilePath);
var messageSubject = "Test";
var messageBody = "Test with attach";
var mailgunData = {
from: ,
to: agentEmail,
subject: messageSubject,
html: messageBody,
attachment: tempFilePath,
};
mailgunAgent.messages().send(mailgunData, function (error, body) {
console.log(body);
});
});
});
나는 기능 로그에서지고있어 오류 메시지는 다음과 같습니다 I가 파일을 다운로드 할 수 있었다있어
ApiError: Forbidden
at Object.parseHttpRespMessage (/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:156:33)
at Object.handleResp (/user_code/node_modules/@google-cloud/storage/node_modules/@google-cloud/common/src/util.js:131:18)
at Duplexify.<anonymous> (/user_code/node_modules/@google-cloud/storage/src/file.js:724:21)
at emitOne (events.js:96:13)
at Duplexify.emit (events.js:188:7)
at emitOne (events.js:96:13)
at DestroyableTransform.emit (events.js:188:7)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at Request.<anonymous> (/user_code/node_modules/@google-cloud/storage/node_modules/request/request.js:1108:14)
요청을 사용하여 디스크의/tmp/폴더를 대체 할 수 있습니다.이 옵션은 대체 옵션이지만 가능한 경우 GCS 도구를 사용하고 싶습니다. 나는 GCS와의 인증 오류라고 생각하지만 그 사실을 추적하는 방법을 모르겠습니다. 파이어 폭스보다 GCS 용 클라우드 함수 .config()에서 다른 인증 매개 변수가 필요합니까? 그렇다면 어떻게 입력합니까? 우리의 GCS 버킷과 프로젝트는 Firebase Storage의 출시를 앞당기지만, 서버에서 실행되는 노드 기능과 함께 성공적으로 사용했습니다. 사전에
감사합니다, 자크는
답장을 보내 주셔서 감사합니다. 불행히도 나는 그것을 시도했지만 작동하지 않습니다. 승인 문제가있을 수 있지만 문제를 추적하는 데 어려움이 있습니다. – Zach