Last active
June 26, 2020 04:52
-
-
Save peterkracik/50fc9b95858659d5758b00fd81e37e3f to your computer and use it in GitHub Desktop.
Get and store firebase storage public url
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
| functions.storage.bucket('my_bucket').object().onFinalize(async (object: functions.storage.ObjectMetadata) => { | |
| const db = admin.firestore(); // initiate firestore db connection | |
| const galleries = db.collection('galleries'); // get reference to collection gallery | |
| // manually create url | |
| const fileUrl = `https://storage.googleapis.com/${object.bucket}/${object.name}`; | |
| //add item to the collection | |
| await galleries.add({ | |
| url: fileUrl, | |
| // ... other properties | |
| }); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment