Search code examples
firebase-storageangularfire2

Cloud Storage for Firebase: download metadata of all files


Question: Is there a way to download the metadata of all the files in Cloud Storage?

Reference: I've taken a look at the documentation for AngularFire2 and while I can do a download of the metadata for one file I can't figure out how to pull the metadata for all the files in the storage. AngularFire2 FireStorage documentation

Code: I'm pulling down the metadata for one file successfully.

Component.TS

 fileUrl: Observable<string>;
 fileCollection: Observable<any>;

 constructor(firestorage: AngularFireStorage) { 
 const ref = firestorage.ref('nforms/').child('file.pdf');
 this.fileUrl = ref.getDownloadURL();
 this.fileCollection = ref.getMetadata();
}

Component.HTML

<tr *ngIf="fileCollection | async; let f">
<td><pre><code>{{f | json}}</code></pre> . 
</td>
<td>f</td>
<div *ngIf="fileUrl | async; let url">
<td><a target="_self" [href]="url">download</a></td>
</div>
</tr>

Current Results

{
  "type": "file",
  "bucket": "this-is-a-secret",
  "generation": "this-is-a-secret",
  "metageneration": "1",
  "fullPath": "nforms/file.pdf",
  "name": "file.pdf",
  "size": 318522,
  "timeCreated": "2019-08-09T21:52:53.692Z",
  "updated": "2019-08-09T21:52:53.692Z",
  "md5Hash": "this-is-a-secret",
  "contentDisposition": "inline; filename*=utf-8''file.pdf",
  "contentEncoding": "identity",
  "contentType": "application/pdf"
}

Solution

  • You will have to list all the files, then access their metadata individually. There aren't any bulk operations on object metadata.