Google 仅对某些对象具有云存储权限
Google cloud storage permission only on some object
我有一个包含多个文件夹的存储桶,每个文件夹包含多个对象 (pdf)。是否可以只允许某些用户只看到特定的对象(如果他可以看到其他文件夹就可以)?
我试图在像这样创建对象后仅对某些对象应用 reader acl 权限:
myFile.acl.add({ entity: 'group-' + email, role: 'READER' })
但是用户看不到存储桶,所以我给了他“Storage Object Viewer”权限,但现在他可以看到所有对象。
组是正确的(我希望),我创建了一个包含特定用户的组。
感谢您的帮助!
通过添加 READER
的角色,您允许用户按照说明 here
列出存储桶内容
Allows a user to list a bucket's contents. Also allows a user to read bucket metadata, excluding ACLs.
为了允许特定用户,您可以使用 addUser 函数:
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
async function addFileReader() {
await storage
.bucket(bucketName)
.file(filename)
.acl.readers.addUser(userEmail);
}
或者如果你想添加一个组:
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
async function addFileReader() {
await storage
.bucket(bucketName)
.file(filename)
.acl.readers.addGroup(groupEmail);
}
您也可以通过 UI:
- 进入
Storage
部分
- 单击要授予访问权限的特定存储桶
- 单击要授予访问权限的特定文件
- 转到
EDIT PERMISSIONS
,在Entity
列select User
或Group
的Name
列中的弹出窗口中输入电子邮件select Reader
在 Access
列
我有一个包含多个文件夹的存储桶,每个文件夹包含多个对象 (pdf)。是否可以只允许某些用户只看到特定的对象(如果他可以看到其他文件夹就可以)?
我试图在像这样创建对象后仅对某些对象应用 reader acl 权限:
myFile.acl.add({ entity: 'group-' + email, role: 'READER' })
但是用户看不到存储桶,所以我给了他“Storage Object Viewer”权限,但现在他可以看到所有对象。
组是正确的(我希望),我创建了一个包含特定用户的组。
感谢您的帮助!
通过添加 READER
的角色,您允许用户按照说明 here
Allows a user to list a bucket's contents. Also allows a user to read bucket metadata, excluding ACLs.
为了允许特定用户,您可以使用 addUser 函数:
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
async function addFileReader() {
await storage
.bucket(bucketName)
.file(filename)
.acl.readers.addUser(userEmail);
}
或者如果你想添加一个组:
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
async function addFileReader() {
await storage
.bucket(bucketName)
.file(filename)
.acl.readers.addGroup(groupEmail);
}
您也可以通过 UI:
- 进入
Storage
部分 - 单击要授予访问权限的特定存储桶
- 单击要授予访问权限的特定文件
- 转到
EDIT PERMISSIONS
,在Entity
列selectUser
或Group
的Name
列中的弹出窗口中输入电子邮件selectReader
在Access
列