public PutACL ( PutACLRequest request ) : PutACLResponse | ||
request | PutACLRequest | Container for the necessary parameters to execute the PutACL service method. |
리턴 | PutACLResponse |
public void TestPostUpload() { var region = RegionEndpoint.USWest1; using (var client = new AmazonS3Client(region)) { var bucketName = S3TestUtils.CreateBucket(client); client.PutACL(new PutACLRequest { BucketName = bucketName, CannedACL = S3CannedACL.BucketOwnerFullControl }); var credentials = GetCredentials(client); try { var response = testPost("foo/bar/content.txt", bucketName, testContentStream("Line one\nLine two\nLine three\n"), "", credentials, region); Assert.IsNotNull(response.RequestId); Assert.IsNotNull(response.HostId); Assert.AreEqual(HttpStatusCode.NoContent, response.StatusCode); } finally { AmazonS3Util.DeleteS3BucketWithObjects(client, bucketName); } } }
public virtual void MakeObjectPublic(AmazonS3Client s3Client, string bucketName, string key) { // Create the request var putAclRequest = new PutACLRequest { BucketName = bucketName, Key = key, CannedACL = S3CannedACL.PublicRead }; // Submit the request s3Client.PutACL(putAclRequest); }
public void AclSamples() { { #region PutACL Sample 1 // Create a client AmazonS3Client client = new AmazonS3Client(); // Set Canned ACL (PublicRead) for an existing item client.PutACL(new PutACLRequest { BucketName = "SampleBucket", Key = "Item1", CannedACL = S3CannedACL.PublicRead }); // Set Canned ACL (PublicRead) for an existing item // (This reverts ACL back to default for object) client.PutACL(new PutACLRequest { BucketName = "SampleBucket", Key = "Item1", CannedACL = S3CannedACL.Private }); #endregion } { #region GetACL\PutACL Samples // Create a client AmazonS3Client client = new AmazonS3Client(); // Retrieve ACL for object S3AccessControlList acl = client.GetACL(new GetACLRequest { BucketName = "SampleBucket", Key = "Item1", }).AccessControlList; // Retrieve owner Owner owner = acl.Owner; // Describe grant S3Grant grant = new S3Grant { Grantee = new S3Grantee { EmailAddress = "*****@*****.**" }, Permission = S3Permission.WRITE_ACP }; // Create new ACL S3AccessControlList newAcl = new S3AccessControlList { Grants = new List<S3Grant> { grant }, Owner = owner }; // Set new ACL PutACLResponse response = client.PutACL(new PutACLRequest { BucketName = "SampleBucket", Key = "Item1", AccessControlList = acl }); #endregion } }