我使用下面的代码但是当我更新代码和pods时出现以下错误:
StorageMetadata'没有会员' downloadURL'
static func uploadVideoToFirebaseStorage(videoUrl: URL, onSuccess: @escaping (_ videoUrl: String) -> Void) {
let videoIdString = NSUUID().uuidString
let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("posts").child(videoIdString)
storageRef.putFile(from: videoUrl, metadata: nil) { (metadata, error) in
if error != nil {
ProgressHUD.showError(error!.localizedDescription)
return
}
if let videoUrl = metadata?.downloadURL()?.absoluteString {
onSuccess(videoUrl)
}
}
}
我怎么能解决这个问题?
更新
答案 0 :(得分:6)
由于新版本删除了StorageMetadata上的downloadURLs属性。使用StorageReference.downloadURL(完成:)获取当前下载URL。
// reference of the file that's you want to download
let ref = storageRef.child("simpleImage.jpg")
// get the download URL
ref.downloadURL { url, error in
if let error = error {
} else {
// Here you can get the download URL for 'simpleImage.jpg'
}
}
您可以从这里获得参考:https://firebase.google.com/support/release-notes/ios#5.0.0