本文整理汇总了C#中Amazon.S3.AmazonS3Client.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonS3Client.Dispose方法的具体用法?C# AmazonS3Client.Dispose怎么用?C# AmazonS3Client.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Amazon.S3.AmazonS3Client
的用法示例。
在下文中一共展示了AmazonS3Client.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RefreshAssetList
public void RefreshAssetList()
{
string SecretKey = null;
string PublicKey = null;
AmazonS3Client Client = new AmazonS3Client(PublicKey, SecretKey);
ListObjectsRequest Request = new ListObjectsRequest
{
BucketName = "assets.minecraft.net",
};
ListObjectsResponse Result;
List<Release> releases = new List<Release>();
do
{
Result = Client.ListObjects(Request);
foreach (S3Object o in Result.S3Objects)
{
string IsSnapshot = "Release";
if(!o.Key.Contains("minecraft.jar")) continue;
if (Regex.IsMatch(o.Key, "[0-9][0-9]w[0-9][0-9]")) IsSnapshot = "Snapshot";
else if (o.Key.Contains("pre")) IsSnapshot = "Pre-release";
releases.Add(new Release { Version = o.Key.Split('/')[0],
Size = (o.Size / 1024).ToString() + "KB",
Uploaded = DateTime.Parse(o.LastModified),
Type = IsSnapshot,
Key = o.Key} );
}
}
while (Result.IsTruncated);
releases.Sort(new Comparison<Release>((x, y) => DateTime.Compare(y.Uploaded, x.Uploaded)));
_Releases.Clear();
foreach (Release r in releases)
{
_Releases.Add(r);
}
Client.Dispose();
Result.Dispose();
}
示例2: Main
public static void Main()
{
Debug.WriteLine("============================================");
Debug.WriteLine("Welcome to the AWS .NET SDK! Ready, Set, Go!");
Debug.WriteLine("============================================");
//The Amazon S3 client allows you to manage buckets and objects programmatically.
IAmazonS3 s3Client = new AmazonS3Client();
try
{
ListBucketsResponse response = s3Client.ListBuckets();
int numBuckets = 0;
if (response.Buckets != null && response.Buckets.Count > 0)
{
numBuckets = response.Buckets.Count;
}
Debug.WriteLine("You have " + numBuckets + " Amazon S3 bucket(s)");
}
catch (Amazon.S3.AmazonS3Exception S3Exception)
{
//AmazonServiceException represents an error response from an AWS service.
//AWS service received the request but either found it invalid or encountered an error trying to execute it.
if (S3Exception.ErrorCode != null && (S3Exception.ErrorCode.Equals("InvalidAccessKeyId") || S3Exception.ErrorCode.Equals("InvalidSecurity")))
{
Debug.WriteLine("Please check the provided AWS Credentials.");
Debug.Write("If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3");
Debug.WriteLine(S3Exception.Message, S3Exception.InnerException);
}
else
{
Debug.WriteLine("Error Message: " + S3Exception.Message);
Debug.WriteLine("HTTP Status Code: " + S3Exception.StatusCode);
Debug.WriteLine("AWS Error Code: " + S3Exception.ErrorCode);
Debug.WriteLine("Request ID: " + S3Exception.RequestId);
}
}
finally
{
s3Client.Dispose();
};
}