错误-元数据?.downloadURL()?. absoluteString

时间:2018-07-06 11:54:38

标签: swift firebase firebase-storage

收到此错误:

  

“类型为'StorageMetadata'的值没有成员'downloadURL'

在代码中,我知道Firebase 5.0.0中有一种用于downloadURL的新方法,但是我不知道如何在我的代码中实现它...

        if let imgData = UIImageJPEGRepresentation(img, 0.2) {

        let imgUid = NSUUID().uuidString

        let metadata = StorageMetadata()

        metadata.contentType = "image/jpeg"

        Storage.storage().reference().child(imgUid).putData(imgData, metadata: metadata) { (metadata, error) in

            if error != nil {

                print("did not upload img")
            } else {

                print("uploaded")

                let downloadURL = metadata?<error_appears>.downloadURL()?.absoluteString

                if let url = downloadURL {

                    self.setUser(img: url)
                }
            }
        }
    }

0 个答案:

没有答案