В параметрах Firebase не определено хранилище. Обновление фотографии профиля в Firebase - PullRequest
0 голосов
/ 10 октября 2019

У меня ошибка при попытке обновить фотографию профиля в базе данных 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)">

1 Ответ

0 голосов
/ 10 октября 2019

Обнаружил ошибку .... никогда не настраивайте мое хранилище внутри firebase. В environment.ts

strorageBucketid: ''

...