火力地堡存储随机返回存储/取消

问题描述 投票:5回答:1

我发现了一个错误,指出上传被用户取消,我从火力存储上传文件时正从单个上传三个错误控制台(所有的同样的错误。我看不出,内码该取消正在取得(假设,因为它表示,其由用户在被取消那么它是在代码中。

  startUpload(event: FileList, item:string) {
    // The File object
    const file = event.item(0);
    console.log(item);

    // Client-side validation example
    if (file.type.split('/')[0] !== 'image') { 
      console.error('unsupported file type')
      return;
    }

    // The storage path
    const path = `test/${new Date().getTime()}_${file.name}`;

    // Totally optional metadata
    const customMetadata = { user: item };

    // The main task
    this.uploadStatus = 'inprogress';
    this.task = this.storage.upload(path, file, { customMetadata })
    const fileRef = this.storage.ref(path);

    // Progress monitoring
    this.percentage = this.task.percentageChanges();
    this.snapshot = this.task.snapshotChanges().pipe(
      tap(snap => {
        if (snap.bytesTransferred === snap.totalBytes) {
          // Update firestore on completion
          this.db.collection('photos').add( { path, size: snap.totalBytes }); 
          this.uploadStatus = "finished";
        }
      }),
      finalize(()=>{
        this.downloadURL = fileRef.getDownloadURL();
        console.log("Final");
      })
    );

}

从铬控制台完整的错误:“存储/取消” code_:“存储/取消”的消息:“火力地堡存储:用户取消了上传/下载。”消息_:“火力地堡存储:用户取消了上传/下载。”名称:(...)名_: “FirebaseError” serverResponse:空serverResponse_:空

火力地堡存储:显示一些工作(尽管我得到的误差)上传:Firebase Randomly works

javascript firebase firebase-storage
1个回答
0
投票

我只是碰到了这个错误我自己:

FirebaseStorageError {code_: "storage/canceled", message_: "Firebase Storage: User canceled the upload/download.", serverResponse_: null, name_: "FirebaseError"}

我原来的观点

 <mat-progress-bar mode="determinate" *ngIf="(uploadPercent | async) == 0" [value]="uploadPercent | async"></mat-progress-bar>
| async

是被取消观察到的罪魁祸首。

解:

        <ng-container *ngIf="(uploadPercent$ | async); let uploadPercent">
            <mat-progress-bar mode="determinate" *ngIf="uploadPercent !== 100" [value]="uploadPercent"></mat-progress-bar>
        </ng-container>
© www.soinside.com 2019 - 2024. All rights reserved.