Skip to content

Example doesn't work with newest version: AngularFireUploadTask.downloadURL(); returns undefined #1645

Closed
@takahser

Description

@takahser

Version info

Angular: "^5.2.1"
Firebase: "^5.0.2"
AngularFire: "5.0.0-rc.7"

It used to work on earlier versions, e.g.:
"angularfire2": "5.0.0-rc.6",
"firebase": "^5.0.2",

How to reproduce these conditions

See the example Monitoring upload percentage

@Component({
  selector: 'app-root',
  template: `
    <input type="file" (change)="uploadFile($event)" />
    <div>{{ uploadPercent | async }}</div>
    <a [href]="downloadURL | async">{{ downloadURL | async }}</a>
 `
})
export class AppComponent {
  uploadPercent: Observable<number>;
  downloadURL: Observable<string>;
  constructor(private storage: AngularFireStorage) {}
  uploadFile(event) {
    const file = event.target.files[0];
    const filePath = 'name-your-file-path-here';
    const task = this.storage.upload(filePath, file);
    
    // observe percentage changes
    this.uploadPercent = task.percentageChanges();
    // get notified when the download URL is available
    this.downloadURL = task.downloadURL();
  }
}

Expected behavior

On the current version, when uploading a file using AngularFireStorage.upload(filePath, file) the downloadUrl of the file can be requested by subscribing to AngularFireUploadTask.downloadURL():

AngularFireUploadTask.downloadURL().subscribe(console.log) // should log download url

Actual behavior

Instead of returning the URL, the subscription returns undefined:

AngularFireUploadTask.downloadURL().subscribe(console.log) // logs undefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions