最近更新时间:2021-10-29
用于转化对象的存储类型,现在可进行的存储类型转换为:S3StorageClass.Standard(标准型)、 S3StorageClass.ReducedRedundancy(低频型)、S3StorageClass.Glacier(归档型)。
以下代码用于设置存储类型转换。
using System; using Amazon.S3; using Amazon.S3.Model;
namespace StorageConversion { class Program { static void Main() { var Ak = "xxx"; var Sk = "xxx"; var endpoint = "http://s3.test.com"; AmazonS3Client serviceClient = new AmazonS3Client(Ak,Sk, new AmazonS3Config{ ServiceURL = endpoint });
try { CopyObjectResponse response; CopyObjectRequest copyObject = new CopyObjectRequest{ SourceBucket = "xxx", SourceKey = "xxx",
DestinationBucket = "xxx", DestinationKey = "xxx", StorageClass = S3StorageClass.Glacier // 归档型 };
response = serviceClient.CopyObjectAsync(copyObject).GetAwaiter().GetResult(); Console.WriteLine(response.HttpStatusCode);
} catch (AmazonS3Exception e) { Console.WriteLine(e.Data); throw; } catch (Exception e) { Console.WriteLine(e); throw; } } } } |