Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 我的firebase数据库值出现权限被拒绝错误,但仅当我读取图像URL时?_Jquery_Database_Firebase_Firebase Realtime Database - Fatal编程技术网

Jquery 我的firebase数据库值出现权限被拒绝错误,但仅当我读取图像URL时?

Jquery 我的firebase数据库值出现权限被拒绝错误,但仅当我读取图像URL时?,jquery,database,firebase,firebase-realtime-database,Jquery,Database,Firebase,Firebase Realtime Database,这些是我的数据库规则 { "rules": { "users":{ 此子对象中存在图像URL "images":{ "$uid":{ ".read":true, ".write": "auth.uid == $uid" } }, "profile":{ "$uid":{ ".read":true, ".write": "auth.uid == $uid"

这些是我的数据库规则

{
  "rules": {
    "users":{
此子对象中存在图像URL

  "images":{
    "$uid":{
      ".read":true,
      ".write": "auth.uid == $uid"
    }
  },
      "profile":{
        "$uid":{
          ".read":true,
          ".write": "auth.uid == $uid"
        }
      }
    }
  }
}
此子对象中还有图像URL

  "images":{
    "$uid":{
      ".read":true,
      ".write": "auth.uid == $uid"
    }
  },
      "profile":{
        "$uid":{
          ".read":true,
          ".write": "auth.uid == $uid"
        }
      }
    }
  }
}
那是我的数据库代码

以下是我在swift代码中使用它的方式:

databaserEF = Database.database.reference.child("users").child("profile").child("images").child(userID!)
 databaserEF.observe(.value, with: {(snapshot) in
            let dictionary = snapshot.value as? NSDictionary
            let photo = dictionary!["HEADSHOT"] as? String
            if photo != "nothing"{
                let url = URL(string: photo!)
                URLSession.shared.dataTask(with: url!, completionHandler: {(data, repone, error) in

                    DispatchQueue.main.async {
                        self.image.image = UIImage(data: data!)
                    }
                }).resume()
            }
        })
这就是我在数据库中组织它的方式


您在引用数据时似乎有错误

您的引用声明当前如下所示:

Database.database.reference.child("users").child("profile").child("images").child(userID!)
Database.database.reference.child("users").child("images").child(userID!)
尽管您的数据库结构建议您删除
.child(“profile”)
,而是像这样声明引用:

Database.database.reference.child("users").child("profile").child("images").child(userID!)
Database.database.reference.child("users").child("images").child(userID!)
取回

{
  'BODYSHOT': 'nothing',
  'HEADSHOT': 'https://firebasestorage.googleapis.com/v0/b/...',
  'SWIMSHOT': 'nothing'
} 

能否请您发布一些示例,说明如何存储数据以及如何尝试查询数据?如何初始化
databaserEF
?请考虑如何创建一个完全独立的问题复制以帮助故障排除。见。@DennisAlund我更新了问题