获取对象访问权限

您可以使用 get_object_acl 接口获取对象访问的权限。以下代码展示如何获取对象的访问权限:

def get_object_acl(client, bucket_name, object_key)
  resp = client.get_object_acl(
    bucket: bucket_name,
    key: object_key
  )
  grants = resp.grants
  puts 'Object 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 object ACL: #{e.message}"
end