首页 > 解决方案 > 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;

    }

  }

}

标签: iosswiftxcodefirebasefirebase-storage

解决方案


推荐阅读