对象相关接口 返回结果 GetObject返回的结果如下: 参数 类型 说明 BucketName string 对象所在桶的名称 ContentLength long 对象数据的长度,单位为字节 ETag string 对象的Entity Tag LastModified DateTime 最后修改对象的时间 TagCount int 对象标签的数量 VersionId string 对象的version id 复制对象 功能说明 CopyObject操作用于根据一个已存在的对象创建新的对象。使用CopyOoject可以复制单个最大为5GB的对象,如果需要复制更大的对象,可以使用UploadPartCopy操作。执行CopyObject操作,必须具有对被拷贝对象的READ权限和对目标桶的WRITE权限。 拷贝生成的对象默认保留原对象的元数据信息,也可以才CopyObject操作中指定新的元数据。拷贝生成的对象不会保留原来的ACL信息,该对象默认是发起CopyObject操作的用户私有的。 CopyObject操作默认拷贝原对象的当前版本数据,如果需要拷贝原对象的指定版本,可以在CopySource中加入version id来拷贝指定的Object版本,如果原对象的version id为删除标记,则不会被拷贝。 代码示例 plaintext using System; using System.Threading.Tasks; using Amazon.Runtime; using Amazon.S3; using Amazon.S3.Model; namespace DotNetSDK.ObjectOperation { public class CopyObjectExample { public static async Task CopyObject() { var accessKey " "; var secretKey " "; var endpoint " "; var sourceBucket " "; var sourceKey " "; var destinationBucket " "; var destinationKey " "; try { var credentials new BasicAWSCredentials(accessKey, secretKey); var conf new AmazonS3Config { ServiceURL endpoint }; var s3Client new AmazonS3Client(credentials, conf); var copyObjectRequest new CopyObjectRequest() { SourceBucket sourceBucket, SourceKey sourceKey, DestinationBucket destinationBucket, DestinationKey destinationKey }; var result await s3Client.CopyObjectAsync(copyObjectRequest); if (result.HttpStatusCode ! System.Net.HttpStatusCode.OK) { Console.WriteLine("fail to copy object, HttpStatusCode:{0}, ErrorCode:{1}.", (int) result.HttpStatusCode, result.HttpStatusCode); return; } Console.WriteLine("copy object from {0}/{1} to {2}/{3}.", sourceBucket, sourceKey, destinationBucket, destinationKey); } catch (Exception e) { Console.WriteLine(e.Message); } } } }
来自: