我正在React,前端和无服务器环境(Firestore + Cloud Functions)中开发WEB应用程序。
我想以具有云功能的zip格式下载Firebase存储中的文件夹,然后在本地下载。
以下代码不起作用。
const {Storage} = require('@google-cloud/storage');
const gcs = new Storage();
const os = require('os');
const path = require('path');
exports.documentDownload = functions.https.onCall((data, context) => {
if (!context.auth) {
// Throwing an HttpsError so that the client gets the error details.
throw new functions.https.HttpsError('failed-precondition', 'auth error');
}
const tempFilePath = path.join(os.tmpdir(), 'sample');
gcs.bucket("gs://xxxxxxxxxxx.com/xxxxxxx").file('sample');
var returnFile = file.download({
destination: tempFilePath,
}).then(() => {
/* */
});
});