ios - Firebase 存储:发生未知错误,请检查服务器响应
问题描述
你好,所以我尝试从这个文档的firebase存储下载我的文件,我一步一步地跟着(实际上我只是复制了> :)),我得到了这个错误:
发生未知错误,请检查服务器响应。
谁能帮我?我的代码:
IBAction func SaveToLocalFile(_ sender: Any) {
storageRef.getData(maxSize: 10 * 1024 * 1034, completion:{ (data, error) in
if let error = error {
print("got Error Fetching data: \(error.localizedDescription)")
return
}
if let data = data {
// self?.PictureView.image = UIImage(data: data)
// print(ImagesArray)
self.imageView.image = UIImage(data: data)
}
})
let islandRef = storageRef
// Create local filesystem URL
let localURL = URL(fileURLWithPath: "https://firebasestorage.googleapis.com/v0/b/salonapp-f1157.appspot.com/o/Services%20Pictures%2FFacial.jpeg?alt=media&token=4e91402d-da9e-408b-9fdc-a0ece1623e9b")
// Download to the local filesystem
let downloadTask = islandRef.write(toFile: localURL) { url, error in
if let error = error {
// Uh-oh, an error occurred!
print(error.localizedDescription)
} else {
// Local file URL for "images/island.jpg" is returned
}
}
}
编辑:这是我的 Firebase 存储规则:
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth == null;
}
}
}
解决方案
推荐阅读
- python - 使用 ImageGrid 为每个网格添加标题
- php - 传递要在 HTML 中的弹出窗口中使用的 ID 变量
- java - Java方法在输入String后输出null
- reactjs - 如何使用 react-three-fiber 渲染金字塔形状?
- stack - 来自 netCDF 文件的堆栈变量
- amazon-web-services - 如何获取 Redshift 用户的时区?
- qt - qmake 安装集的成员是什么?
- python - 如何使用此方法(pd.DataFrame)创建三列,而不是两列?
- apache-spark - 使用 Conda Env 问题运行 PySpark
- javascript - 从 XHTTP 请求传递数据库内容