gpt4 book ai didi

swift - Firebase 存储

转载 作者:行者123 更新时间:2023-11-30 11:08:37 24 4
gpt4 key购买 nike

我尝试将图像上传到 Firebase 存储中,仅供引用,我的应用程序在 Firebase 电话号码身份验证注册下。这是我上传图像的代码:

@IBAction func addBtnClicked(_ sender: UIButton) {

let picker = UIImagePickerController()

picker.delegate = self
picker.allowsEditing = true

present(picker, animated: true, completion: nil)
}

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

var selectedImageFromPicker: UIImage?

if let editedImage = info["UIImagePickerControllerEditedImage"] as? UIImage {
selectedImageFromPicker = editedImage
} else if let originalImage = info["UIImagePickerControllerOriginalImage"] as? UIImage {

selectedImageFromPicker = originalImage
}

if let selectedImage = selectedImageFromPicker {
imageView.image = selectedImage
}

let storageRef = Storage.storage().reference().child("profile_images").child("test01.png")


if let uploadData = UIImagePNGRepresentation(self.imageView.image!) {

storageRef.putData(uploadData, metadata: nil) { (metadata, error) in

if let error = error {
print(error)
return
}


}

dismiss(animated: true, completion: nil)

}

func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
print("canceled picker")
dismiss(animated: true, completion: nil)
}

但是每次编译后,我都会收到以下错误代码:

User does not have permission to access gs://cal-dev.appspot.com/profile_images/test01.png." UserInfo={object=profile_images/test01.png, ResponseBody={ "error": { "code": 403, "message": "Permission denied. Could not perform this operation" }

最佳答案

您是否在 Firebase 控制台中授予了读写权限?您似乎无权将数据写入 firebase..

关于swift - Firebase 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52437435/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com