我正在将图像上传到Firebase存储。但这给了我这样的错误。
“错误”:{ “代码”:400, “ message”:“ rules_version = \” 1 \“不允许在存储桶中列出对象。请将存储安全规则更新为 rules_verison = \“ 2 \”以使用列表。“}
我写了以下这些语句:-
let loginInformation = UserDefaults.standard.dictionary(forKey: "loginInformation")
let userInfo = loginInformation!["firebase_id"] as? String
let filePath = Constant.PROFILE_IMAGE_FOLDER_NAME+userInfo!+"."+extens
// let metaData = StorageMetadata()
// metaData.contentType = "image/"+extens
let storageRef = Storage.storage().reference()
// Create a reference to the file you want to upload
let riversRef = storageRef.child(filePath)
// Upload the file to the path "images/rivers.jpg"
_ = riversRef.putFile(from: localFileUrl as URL, metadata: nil) { metadata, error in
guard let metadata = metadata else {
// Uh-oh, an error occurred!
self.activityIndicator.stopAnimating()
return
}
// Metadata contains file metadata such as size, content-type.
print(String(metadata.size))
// You can also access to download URL after upload.
storageRef.downloadURL { (url, error) in
guard url != nil else {
self.activityIndicator.stopAnimating()
print(error!)
// Uh-oh, an error occurred!
return
}
print(url!)
Database.database().reference().child("credentials").updateChildValues(["userPhoto": url as Any])
}
}
请让我知道是否有人可以纠正我。