When a file is upload to Firebase Storage, you can access an object representing the file in a Firebase Cloud Function via the storage.object().onFinalize() event. This object provides properties such as bucket
and name
.
For example, you might set up the following to access the file when it is created:
exports.generateThumbnails = functions
.storage.object()
.onFinalize(async fileOjbect => {
// Do something here with the storage object (here named fileObject).
});
My question regards how to get that same object via the object storage url of the form:
gs://my-app.appspot.com/photos/new_photo_here.jpeg
I'm having trouble finding the documentation for creating the object from the url. I would like to pass the url to a constructor of some sort that returns the object so I can then access the bucket
and name
properties (without having to do any parsing on my own). Does such a constructor exist? If so where is it documented? Something like this:
const file = storage.object('gs://my-app.appspot.com/photos/new_photo_here.jpeg');
question from:
https://stackoverflow.com/questions/65642526/how-to-create-firebase-storage-object-from-firebase-storage-url 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…