3

I'm developing WEB applications in React, front-end and serverless environment (Firestore + Cloud Functions).

I want to download folders in firebase storage in zip format with cloud functions and download them locally.

The following code does not work.

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(() => {
        /*  */

    });
});
oke
  • 31
  • 3

0 Answers0