获取桶策略

您可以使用 getBucketPolicy 接口获取桶策略。以下代码展示如何获取一个桶的策略:

$bucket = '<your-bucket-name>';
try {
    $resp = $s3Client->getBucketPolicy([
        'Bucket' => $bucket
    ]);
    echo "Succeed in receiving bucket policy:\n";
    echo (string) $resp->get('Policy');
    echo "\n";
} catch (AwsException $e) {
    echo $e->getMessage();
    echo "\n";
}