Cloud Storage for Firebase:下载所有文件的元数据
Cloud Storage for Firebase: download metadata of all files
问:有没有办法下载云存储中所有个文件的元数据?
参考:我查看了 AngularFire2 的文档,虽然我可以下载一个文件的元数据,但我不知道如何提取存储中所有文件的元数据。
AngularFire2 FireStorage documentation
代码:我正在成功提取一个文件的元数据。
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>
当前结果
{
"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"
}
您必须列出所有文件,然后单独访问它们的元数据。没有对对象元数据进行任何批量操作。
问:有没有办法下载云存储中所有个文件的元数据?
参考:我查看了 AngularFire2 的文档,虽然我可以下载一个文件的元数据,但我不知道如何提取存储中所有文件的元数据。 AngularFire2 FireStorage documentation
代码:我正在成功提取一个文件的元数据。
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>
当前结果
{
"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"
}
您必须列出所有文件,然后单独访问它们的元数据。没有对对象元数据进行任何批量操作。