Skip to content

docs(changelog): update storage documentation #1650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 16, 2018
Merged

docs(changelog): update storage documentation #1650

merged 3 commits into from
May 16, 2018

Conversation

renansigolo
Copy link
Contributor

@renansigolo renansigolo commented May 15, 2018

Checklist

Description

Updating the documentation with examples on how to upload files through the methods, put, putString and upload.

Code sample

| ---------|--------------------|
| `snapshotChanges(): Observable<FirebaseStorage.UploadTaskSnapshot>` | Emits the raw `UploadTaskSnapshot` as the file upload progresses. |
| `percentageChanges(): Observable<number>` | Emits the upload completion percentage. |
| `getDownloadURL(): Observable<string>` | Emits the download url when available |
Copy link
Member

@jamesdaniels jamesdaniels May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not on task any longer; might want to point out it's on the ref.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd updated the example with a more thorough description of this change, moreover, I've noticed that the type of the Observable changed to getDownloadURL(): Observable<any>, instead of getDownloadURL(): Observable<string>, thus I've matched the new declaration at the docs. storage ref - line 7

// observe percentage changes
this.uploadPercent = task.percentageChanges();
// get notified when the download URL is available
this.downloadURL = task.downloadURL();
this.downloadURL = fileRef.getDownloadURL();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to wait for task to finish, see Jeff's comment for a good solution #1649 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though I've added Jeff's example, on my tests I was only able to retrieve the url by actually subscribing to the Observable that receives the data from the getDownloadURL() function inside the finalize method.

There's an example

import { finalize } from 'rxjs/operators';

// ...

task
   .snapshotChanges()
     .pipe(
        finalize(() => {
           this.downloadURL = storageRef.getDownloadURL()
           this.downloadURL.subscribe(ref => {
           this.update(this.user, ref)
           })
        })
     )
.subscribe()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jamesdaniels
Copy link
Member

Thanks for taking a pass on this, just a couple small things.

@jamesdaniels jamesdaniels merged commit 5dcc354 into angular:master May 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants