FriendlyPix iOS - 用户没有权限存储错误

时间:2018-04-23 21:18:29

标签: firebase firebase-realtime-database google-cloud-functions firebase-storage

我刚安装了FriendlyPix iOS,并按照自述文件中列出的所有步骤进行操作,包括部署云功能和规则。我收到错误,我认为这与存储规则有关。我得到的错误是:

用户无权访问gs://friendlypixsk.appspot.com/HS4uNP1BYNNnW2Qf59azZH8i3gp2/full/-LAoHLCCMnlD8RoFhUNd/jpeg。

这发生在FPUploadViewController中的uploadPressed函数中。它发生在fullref.downloadURL函数调用中。传递给该函数的闭包是一个错误。

我的Firebase存储规则如下:

// Returns true if the given UID matches the signed in UID,
// the uploaded file is an image and its size is below the given number of MB.
// Also allow deletes.
function isImageAndBelowMaxSize(uid, maxSizeMB) {
  return request.auth.token.admin == true || (request.auth.uid == uid
      && (request.resource == null // Allow deletes
          || request.resource.size < maxSizeMB * 1024 * 1024 // Max size for the uploaded file
              && request.resource.contentType.matches('image/.*'))) // The file is an image
}

service firebase.storage {
  match /b/{bucket}/o {
    match /{userId}/thumb/{postId}/{fileName} {
      allow read, write: if isImageAndBelowMaxSize(userId, 1);
    }
    match /{userId}/full/{postId}/{fileName} {
      allow read, write: if isImageAndBelowMaxSize(userId, 5);
    }
  }
}

我根本没有修改它们。图像确实上传了,我可以在firebase控制台中看到它。我对firebase有点新鲜,并且不确定这些规则是如何工作的。我已使用谷歌登录登录。

非常感谢任何帮助!!

由于

0 个答案:

没有答案