我无法从用户输入中下载图片。每当我尝试上传图像时,都会出现错误屏幕。我正在使用Swift 4.0的Xcode 9。
if let imgData = UIImageJPEGRepresentation(img, 0.2){
let imgUid = NSUUID().uuidString
let metadata = StorageMetadata()
metadata.contentType = "image/jpeg"
let storageItem = Storage.storage().reference().child(imgUid)
storageItem.putData(imgData, 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.setUser(img: url!.absoluteString)
}
}
)
}
}
}