web-dev-qa-db-ja.com

Firebase Storageからフォルダー全体をダウンロードする方法は?

Firebaseストレージからフォルダー全体をダウンロードしたい。次のようにDownloadURLを取得することにより、単一のファイルをダウンロードできます。ただし、フォルダに対しては機能しません。

var storageRef = firebase.storage().ref();

  // Create a reference to the file we want to download
  var starsRef = storageRef.child(path);

  // Get the download URL
  starsRef.getDownloadURL().then(function(url) {
    // Insert url into an <img> tag to "download"
    ImageUrl = url;

    console.log(ImageUrl);
  }).catch(function(error) {
    switch (error.code) {
      case 'storage/object_not_found':
        // File doesn't exist
        break;

      case 'storage/unauthorized':
        // User doesn't have permission to access the object
        break;

      case 'storage/canceled':
        // User canceled the upload
        break;

      case 'storage/unknown':
        // Unknown error occurred, inspect the server response
        break;
    }
  });

Firebaseからフォルダー全体をダウンロードする方法は?

17
isuru

Firebase Storageには、フォルダー内のすべてのファイルをダウンロードするためのAPIはありません。ファイルを1つずつダウンロードするか、すべてのファイルを含むZipファイルを作成する必要があります。

関連:

4

gsutil を使用して、ストレージバケット全体をダウンロードできます。

gsutil -m cp -R gs://<bucket_name> .
19
Lahiru Chandima