2017-02-28 3 views
0

나는 사용자에게 그런 것을 부여하려고합니다.firebase 보관 규칙 일치에 대해

match /images/{userId}/{allPaths=**} 

하지만 내 firebaseStorage 경로는 이와 같습니다.

match /images/user/userId_user.jpg 

그래서이 경로와 일치하는 방법을 모르겠습니다.

그리고 .. 만약 당신이 uid를 사용한다면, {userId}와 일치하는 것을 사용하지 마십시오. <.

종류입니다.

match /users/{userId}/images/{imageId} { 
    allow write: if userId == request.auth.uid; 
} 

하는 /users/userId/images/user.jpeg

을 일치시킬 수 있습니다하지만이 형식에 이미 있다면, 당신은 우리가 문자열을 제공하는 운이 좋다 : 나는 다른 형식으로 파일을 저장하는 것이 좋습니다

답변

1

이 쉽게하기 위해 정규식 일치 :

match /images/user/{userImageName} { 
    // If you know it'll be just a straight string match, go for it 
    allow read if: userImageName == request.auth.uid + '_user.jpeg'; 
    // Otherwise match using a regular expression 
    allow write if: userImageName.matches(request.auth.uid + '_user.jpeg'); 
}