Firebaseクラウド関数の導入により、現在のnode.jsサーバサイドコードの一部をクラウド関数に移行しています。私が抱えている問題の1つは、GCSバケットからディスク上の一時ファイルにファイルをダウンロードし、それを添付ファイルとしてメールで送信することです(mailgun-jsを使用)。firebaseクラウド関数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);
});
});
});
エラーメッセージは次のとおりです。
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の認証エラーだと思っていますが、それをどのように追跡するのかはわかりません。 Firebaseの場合とは異なり、GCSのクラウド関数.config()に異なる認証パラメータを設定する必要がありますか?もしそうなら、私はどのように入力しますか?私たちのGCSバケツとプロジェクトは、Firebase Storageの導入に先行していますが、私たちはサーバ上で稼動するノード機能との併用に成功しました。 GoogleクラウドストレージAPIを使用できるようになる前に特定する必要があり、事前に
おかげで、 ザック
返信いただきありがとうございます。残念ながら私はそれを試みましたが、うまくいきません。私は認証問題があるかもしれないと思っていますが、それを追跡するのに問題があります。 – Zach