Reputation: 25
Storage.storage().reference().child(ImageUid).putData(ImageData, metadata: metadata) { (metadata, error) in
if error != nil {
print("Couldn't Upload Image")
} else {
print("Uploaded")
let downloadURl = metadata?.downloadURL()?.absoluteString
if let url = downloadURl {
self.SetUpUser(Image: url)
}
}
}
}
}
Error:
'downloadURL()' is deprecated: Use
StorageReference.downloadURLWithCompletion()
to obtain a current download URL.
How do I fix this?
Upvotes: 0
Views: 3264
Reputation: 2010
The error says that you need to use StorageReference.downloadURLWithCompletion()
well you need to use it:
let storageItem = Storage.storage().reference().child(ImageUid)
storageItem.putData(ImageData, metadata: metadata) { (metadata, error) in
if error != nil {
print("Couldn't Upload Image")
} else {
print("Uploaded")
storageItem.downloadURL(completion: { (url, error) in
if error != nil {
print(error!)
return
}
if url != nil {
self.SetUpUser(Image: url!.absoluteString)
}
}
}
}
Upvotes: 6