我需要为Firebase存储中的图像获取像这样的下载URL:
在iOS中,我可以使用
来获取链接import Firebase
Storage.storage().reference()child(path).downloadURL { (urlStorage, error) in
if let error = error {
print("there is an error while getting downloadURL String firebase storage: \(error.localizedDescription)")
completion(nil)
} else {
print("successfully get downloadURL String firebase storage firebase storage")
completion(urlStorage?.absoluteString)
}
}
但是这时我需要使用云功能在后台触发中获取链接。如果将图片上传到Firebase存储,则会触发以下代码
import * as admin from 'firebase-admin'
const defaultStorage = admin.storage()
admin.initializeApp()
export const updateUserProfileImagePathAfterUploadingImage = functions.storage.object().onFinalize(async (object) => {
// I don't know what to do in here. I can't access 'child' in 'defaultStorage' to access download URL like in the iOS code
})