本文整理汇总了C#中Amazon.S3.AmazonS3Client.PutACL方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3Client.PutACL方法的具体用法?C# AmazonS3Client.PutACL怎么用?C# AmazonS3Client.PutACL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amazon.S3.AmazonS3Client
的用法示例。
在下文中一共展示了AmazonS3Client.PutACL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPostUpload
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);
}
}
}
示例2: MakeObjectPublic
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);
}
示例3: AclSamples
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 = "[email protected]" },
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
}
}