MCPcopy
hub / github.com/angular/angularfire / StorageComponent

Class StorageComponent

sample/src/app/storage/storage.component.ts:22–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20 imports: [AsyncPipe]
21})
22export class StorageComponent {
23
24 private readonly storage = getStorage(inject(FirebaseApp));
25
26 private readonly transferState = inject(TransferState);
27 private readonly transferStateKey = makeStateKey<string|undefined>("storage:google-g.png");
28
29 private readonly icon = ref(this.storage, 'google-g.png');
30
31 protected readonly downloadUrl$ = from(getDownloadURL(this.icon)).pipe(
32 traceUntilFirst('storage'),
33 isPlatformServer(inject(PLATFORM_ID)) ?
34 tap(it => this.transferState.set(this.transferStateKey, it)) :
35 startWith(this.transferState.get(this.transferStateKey, TRANSPARENT_PNG))
36 );
37
38 constructor() {
39 if (environment.emulatorPorts?.storage) {
40 connectStorageEmulator(this.storage, "localhost", environment.emulatorPorts.storage);
41 }
42 }
43
44}

Callers

nothing calls this directly

Calls 3

traceUntilFirstFunction · 0.90
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected