Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StorageMetadata' has no member 'downloadURL' [duplicate]

i use below code but when i update codes and pods get bellow error:

StorageMetadata' has no member '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)
        }
    }
}

how i can fix this?

update:

new errors

like image 859
felon Avatar asked Jan 28 '23 01:01

felon


1 Answers

As new release removed downloadURLs property on StorageMetadata. Use StorageReference.downloadURL(completion:) to obtain a current download 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'
  }
}

You can get reference from here :https://firebase.google.com/support/release-notes/ios#5.0.0

like image 147
Jogendar Choudhary Avatar answered Feb 09 '23 02:02

Jogendar Choudhary