【问题标题】:No Storage Bucket defined in Firebase Options. Updating Profile Photo into FirebaseFirebase 选项中未定义存储桶。将个人资料照片更新到 Firebase
【发布时间】:2020-02-07 09:12:31
【问题描述】:

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

User.dashboard.html = User.editprofile.html

用户仪表盘.html

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

用户仪表盘.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 @&lt;input type="file" accept="image/*" name="file" id="file" class="uploadPhoto" (change)="uploadPhotoURL($event)"&gt;

【问题讨论】:

  • 请编辑问题以准确说明您如何将 Firebase 集成到您的应用中。似乎缺少配置。

标签: angular firebase firebase-storage angularfire2 angularfire


【解决方案1】:

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

strorageBucketid: ''

【讨论】:

  • 但是现在...我在上传图片时遇到了另一个错误...
  • ERROR FirebaseStorageError {code_: "storage/object-not-found", message_: "Firebase Storage: Object 'users/QF6cFNgdNUX02Cgkx9...DA2/photos/yvon-carre-168[1].jpg'不存在。", serverResponse_: "{↵ "error": {↵ "code": 404,↵ "message": "No...not get object",↵ "status": "GET_OBJECT"↵ }↵}", name_: "FirebaseError"}
猜你喜欢
  • 2020-03-16
  • 1970-01-01
  • 2018-11-09
  • 1970-01-01
  • 1970-01-01
  • 2017-02-23
  • 1970-01-01
  • 2019-10-17
  • 2017-06-14
相关资源
最近更新 更多