【发布时间】:2018-08-30 21:18:45
【问题描述】:
我的 Angular4 应用程序的每个图像上传都需要不同的进度条。 (使用 AngularFireStore 存储)
我的组件
percentageArray = [];
startUpload(event: FileList) {
Array.from(event).forEach(file => {
if (file.type.split('/')[0] != 'image') {
alert('Dieses Dateiformat wird nicht unterstützt');
}
// Storage path
const path = `uploads/${this.currentUserEmail}/${this.uniqueID}/${file.name}`;
// Meta Data
const customMetadata = {
auctionID: this.uniqueID.toString()
}
// Main Task
this.task = this.storage.upload(path, file, {customMetadata});
// Progress Monitoring
this.percentage = this.task.percentageChanges();
this.percentage.subscribe(p => {
this.percentageArray.push(p);
})
this.snapshot = this.task.snapshotChanges();
// File Download Url
this.downloadURL = this.task.downloadURL();
this.imgArray.push(path);
})
}
我的 HTML
<div *ngIf="percentageArray as item" class="w-100">
<div *ngFor="let elem of item">
<ngb-progressbar type="info" [value]="elem" [striped]="true" [max]="100" [showValue]="true"></ngb-progressbar>
</div>
</div>
结果
对于每个状态,我都会获得一个新的进度条...如何强制每次上传将其合并为一个?
【问题讨论】:
标签: angular typescript firebase firebase-storage angularfire2