StorageMetadata'没有成员'downloadURL'

fel*_*lon 3 firebase swift firebase-storage

我使用下面的代码,但当我更新代码和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)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我怎么能解决这个问题?

更新:

新的错误

Jog*_*ary 7

由于新版本删除了StorageMetadata上的downloadURLs属性.使用StorageReference.downloadURL(completion :)获取当前下载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'
  }
}
Run Code Online (Sandbox Code Playgroud)

您可以从此处获得参考:https://firebase.google.com/support/release-notes/ios#5.0.0