最近更新时间:2021-10-29
以下代码用于获取桶的访问权限。
| using System; using Amazon.S3; using Amazon.S3.Model; 
 namespace GetACL { class Program { static void Main(string[] args) { var Ak = "xxx"; var Sk = "xxx"; var endpoint = "http://s3.test.com"; AmazonS3Client serviceClient = new AmazonS3Client(Ak,Sk, new AmazonS3Config{ ServiceURL = endpoint }); 
 try { GetACLResponse response; GetACLRequest putRequest = new GetACLRequest { BucketName = "xxx" }; 
 response = serviceClient.GetACLAsync(putRequest).GetAwaiter().GetResult(); Console.WriteLine("Owner is :{0}", response.AccessControlList.Owner.DisplayName); 
 foreach (S3Grant g_value in response.AccessControlList.Grants) { Console.WriteLine("Permission: {0}", g_value.Permission); } 
 } catch (AmazonS3Exception e) { Console.WriteLine(e.Message); throw; } catch (Exception e) { Console.WriteLine(e); throw; } 
 } 
 } } | 
