-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Added storage download url pipe #2089
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
005277d
added storage url pipe
b7f2ca4
added storage url pipe
6acb6ff
typo
AckerApple b17e974
Merge branch 'master' into master
jamesdaniels bb99b84
Update storageUrl.pipe.ts
jamesdaniels 47b5cfa
Update storage.module.ts
jamesdaniels 095548a
Update storage.spec.ts
jamesdaniels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { Pipe } from '@angular/core'; | ||
| import { AngularFireStorage } from '../storage'; | ||
|
|
||
| /** to be used with in combination with | async */ | ||
| @Pipe({ | ||
| name: 'ngfbStorageUrl' | ||
| }) export class AngularFirestoreStorageUrl implements PipeTransform { | ||
| constructor(public storage: AngularFireStorage) {} | ||
|
|
||
| transform(path) { | ||
| return this.storage.ref(path).getDownloadURL(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| import { NgModule } from '@angular/core'; | ||
| import { AngularFireStorage } from './storage'; | ||
| import { AngularFirestoreStorageUrl } from './pipes/storageUrl.pipe'; | ||
|
|
||
| @NgModule({ | ||
| declarations: [ AngularFirestoreStorageUrl ], | ||
| providers: [ AngularFireStorage ] | ||
| }) | ||
| export class AngularFireStorageModule { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could call this
downloadURL,getDownloadURL,storageDownloadURLor something to that effect, @davideast any thoughts?Could we make it so this was an async pipe itself so it didn't have to be combined with async? So the developer could just do
'someref.jpeg' | storageDownloadURL... or maybe then we call itasyncDownloadURL?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My experience and recommendation is to avoid being too generic as to avoid name collisions as this type of functionality is common to convert a string to a url.
Also, if you removed the need for the async pipe, appending a dollar sign
ngfbStorageUrl$is a standard I’ve read to be clear that an in template variable is or is going through an observable process. It’s a practice to make clear something async is at play. I actually recommend against removing the need for the async pipe OR offer both (one pipe with a trailing $ sign and one without)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both would be cool, but we could scope as a separate PR if you felt so inclined.
How about
getFirebaseDownloadURLandfirebaseDownloadURL$for naming then? That way it's super clear.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that a lot. Great collaboration. I’d like to have this code in my project, how can I help move this along?
I can make the changes but perhaps @davideast would like throw an opinion in the hat?
Thank you very kindly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ps, I don’t know how to have a pipe that has to be async not require the async pipe.
The end all be all maybe that the async pipe is actually a requirement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to “spam”
Here is dollar sign suffix docs:
https://angular.io/guide/rx-library#naming-conventions-for-observables