現在 フロントエンドをReactとサーバレス環境(Firestore + Cloud Functions)にてWEBの開発を行なっています。
firebase storage内のフォルダをローカルにダウンロードしたく、Cloud Functions for Firebaseでフォルダをzip形式に圧縮してのダウンロードを考えています。
似たような質問が投稿されていた(https://teratail.com/questions/114839)のですが、localのダウンロードまでは解決できておりません。
またcloud functionの関数の呼び出しにつきましては、functions.https.onCall にて行おうとしています。
node
1const {Storage} = require('@google-cloud/storage'); 2const gcs = new Storage(); 3const os = require('os'); 4const path = require('path'); 5 6exports.documentDownload = functions.https.onCall((data, context) => { 7 if (!context.auth) { 8 // Throwing an HttpsError so that the client gets the error details. 9 throw new functions.https.HttpsError('failed-precondition', 'auth error'); 10 } 11 12 const tempFilePath = path.join(os.tmpdir(), 'sample'); 13 gcs.bucket("gs://xxxxxxxxxxx.com/xxxxxxx").file('sample'); 14 15 var returnFile = file.download({ 16 destination: tempFilePath, 17 }).then(() => { 18 /* */ 19 20 }); 21});
あなたの回答
tips
プレビュー