本文整理汇总了C#中Amazon.S3.AmazonS3Client.GetACL方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3Client.GetACL方法的具体用法?C# AmazonS3Client.GetACL怎么用?C# AmazonS3Client.GetACL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amazon.S3.AmazonS3Client
的用法示例。
在下文中一共展示了AmazonS3Client.GetACL方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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
}
}
示例2: GetS3Buckets
//.........这里部分代码省略.........
}
var pointy = RegionEndpoint.GetBySystemName(region);
//Build a config that references the buckets region.
AmazonS3Config S3C = new AmazonS3Config();
S3C.RegionEndpoint = pointy;
AmazonS3Client BS3Client = new AmazonS3Client(credential, S3C);
var authregion = "";
var EP = BS3Client.Config.RegionEndpoint.DisplayName;
if (String.IsNullOrEmpty(BS3Client.Config.RegionEndpoint.DisplayName)) authregion = "";
else
{
authregion = BS3Client.Config.AuthenticationRegion;
}
string authservice = "";
if (string.IsNullOrEmpty(BS3Client.Config.AuthenticationServiceName)) authservice = "";
else
{
authservice = BS3Client.Config.AuthenticationServiceName;
}
var createddate = abucket.CreationDate;
string owner = "";
string grants = "";
string tags = "";
string lastaccess = "";
string defaultpage = "";
string website = "";
//Now start pulling der einen data.
GetACLRequest GACR = new GetACLRequest();
GACR.BucketName = name;
var ACL = BS3Client.GetACL(GACR);
var grantlist = ACL.AccessControlList;
owner = grantlist.Owner.DisplayName;
foreach (var agrant in grantlist.Grants)
{
if (grants.Length > 1) grants += "\n";
var gName = agrant.Grantee.DisplayName;
var gType = agrant.Grantee.Type.Value;
var aMail = agrant.Grantee.EmailAddress;
if (gType.Equals("Group"))
{
grants += gType + " - " + agrant.Grantee.URI + " - " + agrant.Permission + " - " + aMail;
}
else
{
grants += gName + " - " + agrant.Permission + " - " + aMail;
}
}
GetBucketWebsiteRequest GBWReq = new GetBucketWebsiteRequest();
GBWReq.BucketName = name;
GetBucketWebsiteResponse GBWRes = BS3Client.GetBucketWebsite(GBWReq);
defaultpage = GBWRes.WebsiteConfiguration.IndexDocumentSuffix;
if (defaultpage != null)
{
website = @"http://" + name + @".s3-website-" + region + @".amazonaws.com/" + defaultpage;
}
示例3: ScanProfile
//.........这里部分代码省略.........
#region S3Details
try {
AmazonS3Client S3Client = new AmazonS3Client(credential,Amazon.RegionEndpoint.USEast1);
ListBucketsResponse response = S3Client.ListBuckets();
foreach (S3Bucket abucket in response.Buckets)
{
DataRow abucketrow = GetS3DetailsTable().NewRow();
var name = abucket.BucketName;
GetBucketLocationRequest gbr = new GetBucketLocationRequest();
gbr.BucketName=name;
GetBucketLocationResponse location = S3Client.GetBucketLocation(gbr);
var region = location.Location.Value;
if (region.Equals(""))region="us-east-1";
var pointy = RegionEndpoint.GetBySystemName(region);
//Build a config that references the buckets region.
AmazonS3Config S3C = new AmazonS3Config();
S3C.RegionEndpoint=pointy;
AmazonS3Client BS3Client = new AmazonS3Client(credential, S3C);
var createddate = abucket.CreationDate;
string owner = "";
string grants = "";
string tags = "";
string lastaccess = "";
string defaultpage = "";
string website = "";
//Now start pulling der einen data.
GetACLRequest GACR = new GetACLRequest();
GACR.BucketName = name;
var ACL = BS3Client.GetACL(GACR);
var grantlist = ACL.AccessControlList;
owner = grantlist.Owner.DisplayName;
foreach (var agrant in grantlist.Grants)
{
if (grants.Length > 1) grants += "\n";
var gName = agrant.Grantee.DisplayName;
var gType = agrant.Grantee.Type.Value;
var aMail = agrant.Grantee.EmailAddress;
if (gType.Equals("Group"))
{
grants += gType + " - " + agrant.Grantee.URI + " - " + agrant.Permission + " - " + aMail ;
}
else
{
grants += gName + " - "+ agrant.Permission + " - " + aMail;
}
}
GetObjectMetadataRequest request = new GetObjectMetadataRequest();
request.BucketName = name;
GetObjectMetadataResponse MDresponse = BS3Client.GetObjectMetadata(request);
lastaccess = MDresponse.LastModified.ToString();
//defaultpage = MDresponse.WebsiteRedirectLocation;
GetBucketWebsiteRequest GBWReq = new GetBucketWebsiteRequest();
GBWReq.BucketName = name;
GetBucketWebsiteResponse GBWRes = BS3Client.GetBucketWebsite(GBWReq);
defaultpage = GBWRes.WebsiteConfiguration.IndexDocumentSuffix;