Firebase选项中未定义存储桶。将个人资料照片更新为Firebase

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

[尝试将个人资料照片更新到Firebase数据库时出现错误。

User.dashboard.html = User.editprofile.html

user-dashboard.html

<input type="file" accept="image/*" name="file" id="file"
 class="uploadPhoto" (change)="uploadPhotoURL($event)">

user-dashboard.ts

import { AngularFireStorage, AngularFireUploadTask} from '@angular/fire/storage';

  task: AngularFireUploadTask;

  constructor(
    private auth: AuthService,
    private userService: UserService,
    private storage: AngularFireStorage,
  ) { }
 uploadPhotoURL(event): void {
    const file = event.target.files[0];
    const path = `users/${this.user.uid}/photos/${file.name}`;
    if (file.type.split('/')[0] !== 'image') {
      return alert('only images allowed'); // When this is not an image!
    } else {
      this.task = this.storage.upload(path, file);

      // add this ref
      const ref = this.storage.ref(path);

      // and change the observable here
      ref.getDownloadURL().subscribe(url => {
        this.userService.updateProfileData(this.user.displayName, url);
      });
    }
  }

插入img文件后,文件应自动上传到我的数据库中。

但是我遇到此错误:

错误错误:在Firebase选项中未定义存储桶。 @ user.dashboard.html @ <input type="file" accept="image/*" name="file" id="file" class="uploadPhoto" (change)="uploadPhotoURL($event)">

angular firebase firebase-storage angularfire2 angularfire
1个回答
0
投票

发现错误。...永远不要在Firebase中配置我的存储。在environment.ts

strorageBucketid:”

© www.soinside.com 2019 - 2024. All rights reserved.