| 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 | } |