MCPcopy Index your code
hub / github.com/NativeScript/firebase / uploadFile

Method uploadFile

apps/demo/src/plugin-demos/firebase-storage.ts:51–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49 }
50
51 uploadFile() {
52 const file = File.fromPath(
53 path.join(knownFolders.currentApp().path, 'images', 'deadpool.jpeg')
54 )
55 const metadata = new Metadata();
56 metadata.contentType = 'image/jpg';
57 this.storage
58 .ref()
59 .child('images/deadpool.jpeg')
60 .putFile(file.path, metadata)
61 .on(TaskEvent.STATE_CHANGED, {
62 complete() {
63 console.info('uploadFile', 'completed');
64 },
65 error(err) {
66 console.error('uploadFile', 'error', err);
67 },
68 next(snapshot) {
69 console.info('uploadFile', 'next', 'state', snapshot.state);
70 if (snapshot.totalBytes) {
71 console.log('uploadFile', 'next', 'progress %', snapshot.bytesTransferred / snapshot.totalBytes ?? 0 * 100);
72 }
73 if (snapshot.error) {
74 console.error('uploadFile', 'next', snapshot.error);
75 }
76 },
77 });
78 }
79}

Callers

nothing calls this directly

Calls 4

onMethod · 0.65
putFileMethod · 0.65
childMethod · 0.65
refMethod · 0.65

Tested by

no test coverage detected