【发布时间】:2021-10-25 22:37:16
【问题描述】:
您好,我正在使用 Firebase 存储来存储一些图像。
我一直在使用这些访问规则
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
但现在我想创建一个“小障碍”,所以我正在使用它
rules_version = '2';
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write: if request.auth != null;
}
}
}
问题是我不知道如何验证我的请求
这在规则更改之前有效
await storage.ref('images/' + id).put(image.data, {contentType: image.mimetype})
但现在我做不到,所以我尝试了一些方法,但它不起作用
await storage.ref('images/' + id).put(image.data, {
contentType: image.mimetype,
auth: true
})
await storage.ref('images/' + id).put(image.data, {
contentType: image.mimetype,
auth: {
uid: "",
token: {
sub: "",
aud: "x",
email: "",
email_verified: false,
phone_number: "",
name: "",
firebase: {
sign_in_provider: "google.com"
}
}
}
})
await storage.ref('images/' + id).put(image.data, {
contentType: image.mimetype,
request: {
auth: {
uid: ""
}
}
})
【问题讨论】:
标签: firebase firebase-storage firebase-security