Firebase存储错误 - FIRStorageErrorDomain代码= -13021“用户无权访问”

时间:2016-07-19 19:56:11

标签: swift

我有一个问题,我已经处理了一段时间。基本上我试图将Firebase存储中的图像抓取到我的UICollectionView中。

当我转向那个VC时,只有90%的图像加载。当我向下滚动并向后滚动其余的负载时......我不知道为什么。

以下是错误代码:

ResponseErrorDomain=com.google.HTTPStatus, data=<7b0a2020 22657272 6f72223a 207b0a20 20202022 636f6465 223a2034 30332c0a 20202020 226d6573 73616765 223a2022 44657665 6c6f7065 72206372 6564656e 7469616c 73207265 71756972 65642e22 0a20207d 0a7d>, bucket=project-355640.appspot.com, ResponseErrorCode=403, NSLocalizedDescription=User does not have permission to access gs://project-355640.appspot.com/(null).})
Optional(Error Domain=FIRStorageErrorDomain Code=-13021 "User does not have permission to access gs://project-3550640.appspot.com/(null)." UserInfo={ResponseBody={
  "error": {
    "code": 403,
    "message": "Developer credentials required.

以下是创建单元格的方法:

 func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("StoreViewCell", forIndexPath: indexPath)



        if let view = cell as? storeViewCell {

            //Problem is that every time we scroll the images are reloaded from server.
            /// See if yo ucan cache the images somehow and only use those images or cancel the reload.


            view.storeGunName.text = self.playerData.basicGunDict[indexPath.item]["model"]
            view.storeGunPrice.text = "$\(self.playerData.basicGunDict[indexPath.item]["price"]!)"

            if self.playerData.basicGunDict[indexPath.item]["available"] == "yes" {

                let currentImg = storageRef.child(self.playerData.basicGunDict[indexPath.item]["u-image"]!)

                currentImg.dataWithMaxSize(1 * 1024 * 1024, completion: {
                    (data, error) -> Void in

                    if (error != nil) {
                        print(error.debugDescription)
                    } else {
                        view.storeGunImage.image = UIImage(data: data!)
                    }

                })


            } else {

                let currentImg = storageRef.child(self.playerData.basicGunDict[indexPath.item]["l-image"]!)

                currentImg.dataWithMaxSize(1 * 1024 * 1024, completion: {
                    (data, error) -> Void in

                    if (error != nil) {
                        print(error.debugDescription)
                    } else {
                        view.storeGunImage.image = UIImage(data: data!)
                    }

                })

            }


            print("PER CELL \(self.playerData.basicGunDict[indexPath.item])")

        }
        return cell
    }



service firebase.storage {
  match /b/project-3550640.appspot.com/o {
    match /{allPaths=**} {
      allow read, write: if request.auth != null;
    }
  }
}

0 个答案:

没有答案