本文整理汇总了C#中IAmazonS3.CopyObject方法的典型用法代码示例。如果您正苦于以下问题:C# IAmazonS3.CopyObject方法的具体用法?C# IAmazonS3.CopyObject怎么用?C# IAmazonS3.CopyObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAmazonS3
的用法示例。
在下文中一共展示了IAmazonS3.CopyObject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenameObject
private void RenameObject(string oldPath, string newPath, IAmazonS3 client)
{
CopyObjectRequest copyRequest = new CopyObjectRequest();
copyRequest.SourceBucket = BucketName;
copyRequest.SourceKey = oldPath;
copyRequest.DestinationBucket = BucketName;
copyRequest.DestinationKey = newPath;
copyRequest.CannedACL = S3CannedACL.PublicRead;
client.CopyObject(copyRequest);
}
示例2: SetWebsiteRedirectLocation
///// <summary>
///// Sets the redirect location for the S3 Object's when being accessed through the S3 website endpoint.
///// </summary>
///// <param name="s3Object">The S3 Object</param>
///// <param name="websiteRedirectLocation">The redirect location</param>
///// <param name="s3Client">The Amazon S3 Client to use for S3 specific operations.</param>
//public static void SetWebsiteRedirectLocation(S3Object s3Object, string websiteRedirectLocation, IAmazonS3 s3Client)
//{
// SetWebsiteRedirectLocation(s3Object.BucketName, s3Object.Key, websiteRedirectLocation, s3Client);
//}
/// <summary>
/// Sets the redirect location for the S3 Object's when being accessed through the S3 website endpoint.
/// </summary>
/// <param name="bucketName">The name of the bucket in which the key is stored</param>
/// <param name="key">The key of the S3 Object</param>
/// <param name="websiteRedirectLocation">The redirect location</param>
/// <param name="s3Client">The Amazon S3 Client to use for S3 specific operations.</param>
public static void SetWebsiteRedirectLocation(IAmazonS3 s3Client, string bucketName, string key, string websiteRedirectLocation)
{
CopyObjectRequest copyRequest;
PutACLRequest putACLRequest;
SetupForObjectModification(s3Client, bucketName, key, null, out copyRequest, out putACLRequest);
copyRequest.WebsiteRedirectLocation = websiteRedirectLocation;
CopyObjectResponse copyResponse = s3Client.CopyObject(copyRequest);
if (!string.IsNullOrEmpty(copyResponse.SourceVersionId))
putACLRequest.VersionId = copyResponse.SourceVersionId;
s3Client.PutACL(putACLRequest);
}
示例3: SetObjectStorageClass
///// <summary>
///// Sets the storage class for the S3 Object Version to the value
///// specified.
///// </summary>
///// <param name="s3ObjectVer">The S3 Object Version whose storage class needs changing</param>
///// <param name="sClass">The new Storage Class for the object</param>
///// <param name="s3Client">The Amazon S3 Client to use for S3 specific operations.</param>
///// <seealso cref="T:Amazon.S3.Model.S3StorageClass"/>
//public static void SetObjectStorageClass(S3ObjectVersion s3ObjectVer, S3StorageClass sClass, IAmazonS3 s3Client)
//{
// SetObjectStorageClass(s3ObjectVer.BucketName, s3ObjectVer.Key, s3ObjectVer.VersionId, sClass, s3Client);
//}
/// <summary>
/// Sets the storage class for the S3 Object's Version to the value
/// specified.
/// </summary>
/// <param name="bucketName">The name of the bucket in which the key is stored</param>
/// <param name="key">The key of the S3 Object whose storage class needs changing</param>
/// <param name="version">The version of the S3 Object whose storage class needs changing</param>
/// <param name="sClass">The new Storage Class for the object</param>
/// <param name="s3Client">The Amazon S3 Client to use for S3 specific operations.</param>
/// <seealso cref="T:Amazon.S3.Model.S3StorageClass"/>
public static void SetObjectStorageClass(IAmazonS3 s3Client, string bucketName, string key, string version, S3StorageClass sClass)
{
CopyObjectRequest copyRequest;
PutACLRequest putACLRequest;
SetupForObjectModification(s3Client, bucketName, key, version, out copyRequest, out putACLRequest);
copyRequest.StorageClass = sClass;
CopyObjectResponse copyResponse = s3Client.CopyObject(copyRequest);
if (!string.IsNullOrEmpty(copyResponse.SourceVersionId))
putACLRequest.VersionId = copyResponse.SourceVersionId;
s3Client.PutACL(putACLRequest);
}
示例4: SetServerSideEncryption
///// <summary>
///// Sets the server side encryption method for the S3 Object Version to the value
///// specified.
///// </summary>
///// <param name="s3ObjectVer">The S3 Object Version</param>
///// <param name="method">The server side encryption method</param>
///// <param name="s3Client">The Amazon S3 Client to use for S3 specific operations.</param>
//public static void SetServerSideEncryption(S3ObjectVersion s3ObjectVer, ServerSideEncryptionMethod method, IAmazonS3 s3Client)
//{
// SetServerSideEncryption(s3ObjectVer.BucketName, s3ObjectVer.Key, s3ObjectVer.VersionId, method, s3Client);
//}
/// <summary>
/// Sets the server side encryption method for the S3 Object's Version to the value
/// specified.
/// </summary>
/// <param name="bucketName">The name of the bucket in which the key is stored</param>
/// <param name="key">The key of the S3 Object</param>
/// <param name="version">The version of the S3 Object</param>
/// <param name="method">The server side encryption method</param>
/// <param name="s3Client">The Amazon S3 Client to use for S3 specific operations.</param>
public static void SetServerSideEncryption(IAmazonS3 s3Client, string bucketName, string key, string version, ServerSideEncryptionMethod method)
{
CopyObjectRequest copyRequest;
PutACLRequest putACLRequest;
SetupForObjectModification(s3Client, bucketName, key, version, out copyRequest, out putACLRequest);
copyRequest.ServerSideEncryptionMethod = method;
CopyObjectResponse copyResponse = s3Client.CopyObject(copyRequest);
if (!string.IsNullOrEmpty(copyResponse.SourceVersionId))
putACLRequest.VersionId = copyResponse.SourceVersionId;
s3Client.PutACL(putACLRequest);
}
示例5: Recycle
private void Recycle(IAmazonS3 client, string domain, string key)
{
if (string.IsNullOrEmpty(_recycleDir)) return;
var copyObjectRequest = new CopyObjectRequest
{
SourceBucket = _bucket,
SourceKey = key,
DestinationBucket = _bucket,
DestinationKey = GetRecyclePath(key),
CannedACL = GetDomainACL(domain),
MetadataDirective = S3MetadataDirective.REPLACE,
ServerSideEncryptionMethod = ServerSideEncryptionMethod.AES256
};
client.CopyObject(copyObjectRequest);
}