让downloadURL =元数据?.downloadURL()?. absoluteString

时间:2018-08-21 21:55:33

标签: swift firebase firebase-storage

我阅读了很多有关堆栈溢出的问题,但是由于某种原因,我无法为我的任务找到解决方案。也许有人真的可以帮助我。我是菜鸟,并且坚持了好几天!!!

let downloadURL = metadata?.downloadURL()?.absoluteString

我需要运行此功能,但不知道如何在正确的功能中进行设置。我知道不建议使用downloadURL,因此出现以下错误:

  

“ StorageMetadata”类型的值没有成员“ downloadURL”

func setupUser(userUid: String) {
    if let imageData = UIImageJPEGRepresentation(self.userImgView.image!, 0.2) {
        let imgUid = NSUUID().uuidString
        let metaData = StorageMetadata()
        Storage.storage().reference().child(imgUid).putData(imageData, metadata: metaData) { (metadata, error) in

            let downloadURL = metadata?.downloadURL()?.absoluteString

            let userData = [
                "username": self.usernameField.text!,
                "userImg": downloadURL!
                ] as [String : Any]

            Database.database().reference().child("users").child(userUid).setValue(userData)
            self.performSegue(withIdentifier: "toFeed", sender: nil)
        }
    }
}

0 个答案:

没有答案