获取桶访问权限
您可以使用 get_bucket_acl 接口获取桶的访问权限。要获取存储桶的ACL,您必须对存储桶具有 READ_ACP 访问权限。以下代码展示如何获取桶的访问权限:
def get_bucket_acl(client, bucket_name)
resp = client.get_bucket_acl({ bucket: bucket_name })
grants = resp.grants
puts "Bucket ACL:"
i = 0
grants.count.times do
puts "id: #{grants[i].grantee.id}, permission: #{grants[i].permission}"
i += 1
end
rescue StandardError => e
puts "Error getting bucket ACL: #{e.message}"
end