今天,当我尝试更新Firebase存储规则时,收到了有关升级它们的消息。我该怎么办?
i deploying storage
i firebase.storage: checking storage.rules for compilation errors...
⚠ [W] undefined:undefined - Ruleset uses old version (version [1]). Please update to the latest version (version [2]).
✔ firebase.storage: rules file storage.rules compiled successfully
i storage: uploading rules storage.rules...
✔ storage: released rules storage.rules to firebase.storage
我的规则如下:
service firebase.storage {
match /b/{bucket}/o {
match /user-files/{uid}/{allPaths=**} {
allow read: if resource.metadata[request.auth.uid] == "1"; // the uploading user can get a downloadURL
allow create, update: if request.auth.uid == uid // User can only upload to the users own folder
&& request.auth.token.storageLeft >= request.resource.size
&& request.auth.token.path == request.resource.name
allow delete: if false; // files are only deleted by cloud functions
}
}
}
要将规则切换到版本2,请在顶部添加以下行:
rules_version = "2";