我正在嘗試使用 Firebase Storage JS SDK 上傳影像,其中包含一些基于 Firestore 資料的規則。
imageList.forEach(element => {
tasks.push(firebaseStorage.child("Devices").child(dateTime).child(element.name).put(element, { contentType: element.type }))
});
規則:
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /Devices/{deviceId} {
// Authentication is required.
allow create: if request.auth.uid != null &&
// Only Admins are capable of uploading images.
firestore.exists(/databases/(default)/documents/Admins/$(request.auth.uid));
// Authentication is required.
allow read: if request.auth.uid != null &&
// Only Cashiers are capable of reading images.
firestore.exists(/databases/(default)/documents/Cashiers/$(request.auth.uid));
// No update or deletion of files in client (web) for now.
allow update, delete: if false
}
}
}
這就是我得到的。知道這里出了什么問題嗎?TIA。

上傳需要讀寫權限嗎?
uj5u.com熱心網友回復:
match /Devices/{deviceId}匹配僅適用于目錄中的檔案/Devices。如果必須將規則應用于deviceId子目錄中的檔案,則路徑必須是:
match /Devices/{deviceId}/{fileName} {
// ...
}
如果必須將規則遞回應用于所有子目錄,則使用通配符:
match /Devices/{device=**}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/516632.html
標籤:Google Cloud Collective 火力基地firebase-存储firebase-安全
