当前位置 : 主页 > 手机开发 > 其它 >

swift – 类型’StorageReference’的值没有成员’put’

来源:互联网 收集:自由互联 发布时间:2021-06-12
参见英文答案 Upgrading Firebase broke my iOS project1个 我更新到firebase存储4.0,现在我得到这个错误,说storageRef没有成员“put”.它曾在旧版本的Firebase中运行. if let selectedImage = selectedImageFromPick
参见英文答案 > Upgrading Firebase broke my iOS project                                    1个
我更新到firebase存储4.0,现在我得到这个错误,说storageRef没有成员“put”.它曾在旧版本的Firebase中运行.

if let selectedImage = selectedImageFromPicker {
        profilePic.image = selectedImage
        if let uploadData = UIImagePNGRepresentation(selectedImage) {
            let storageRef = Storage.storage().reference().child("profile pictures").child("\(Auth.auth().currentUser?.uid).png")
            storageRef.put/*error here*/(uploadData, metadata: nil, completion: {
                (metadata, error) in
                if error != nil {
                    print(error!)
                    return
                }
                print(metadata!)

                if let profilePictureURL = metadata?.downloadURL()?.absoluteString {

                    let ref = FIRDatabase.database().reference()
                    let usersreference = ref.child("users").child(Auth.auth().currentUser?.uid).child("data")
                    usersreference.updateChildValues(["profile picture": profilePictureURL])
                }
            })
        }
    }
根据Firebase的 migration support,它已被更改为putData(_:metadata:completion
网友评论