2017-02-28 63 views
0

我想授予用戶類似的東西。關於Firebase存儲規則匹配

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

但我的firebaseStorage路徑是這樣的。

match /images/user/userId_user.jpg 

所以我不知道如何匹配這條路徑。

而且..如果您知道使用uid,請不要使用匹配{userId} < - 就像那樣。

親切的關注。

回答

1

我建議在存儲不同格式文件來簡化這一過程:

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

可以匹配/users/userId/images/user.jpeg

但是,如果你在這個格式是已經,你是幸運的,我們提供的字符串和正則表達式匹配:

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'); 
}