Firebase downloadUrl()已弃用

时间:2018-06-26 11:20:26

标签: swift firebase

您能帮忙吗:不建议使用“ downloadURL()”:使用StorageReference.downloadURLWithCompletion()获取当前的下载URL。

Storage.storage().reference().child("profile_images").child(filename).putData(uploadData, metadata: nil, completion: { (metadata, err) in
                if let err = err {
                    print("Failed to upload profile image:", err)
                    return
                }
                guard let profileImageUrl = metadata?.downloadURL()?.absoluteString else { return }
                print("Successfully uploaded profile image:", profileImageUrl)
                guard let uid = user?.uid else { return }

                let dictionaryValues = ["username": username, "profileImageUrl": profileImageUrl]
                let values = [uid: dictionaryValues]
                Database.database().reference().child("users").updateChildValues(values, withCompletionBlock: { (err, ref) in

                    if let err = err {
                        print("Failed to save user info into db:", err)
                        return
                    }

                    print("Successfully saved user info to db")
                })
            })

0 个答案:

没有答案