本文整理汇总了C#中Amazon.S3.Model.CopyObjectRequest类的典型用法代码示例。如果您正苦于以下问题:C# CopyObjectRequest类的具体用法?C# CopyObjectRequest怎么用?C# CopyObjectRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CopyObjectRequest类属于Amazon.S3.Model命名空间,在下文中一共展示了CopyObjectRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyObject
public void CopyObject(Uri sourceUri, Uri destinationUri)
{
CheckUri(sourceUri);
CheckUri(destinationUri);
try
{
var sourceKey = HttpUtility.UrlDecode(sourceUri.AbsolutePath).TrimStart('/');
var destinationKey = HttpUtility.UrlDecode(destinationUri.AbsolutePath).TrimStart('/');
using (var client = CreateAmazonS3Client())
{
var request = new CopyObjectRequest()
.WithSourceBucket(bucketName)
.WithDestinationBucket(bucketName)
.WithCannedACL(S3CannedACL.PublicRead)
.WithSourceKey(sourceKey)
.WithDestinationKey(destinationKey)
.WithDirective(S3MetadataDirective.COPY);
client.CopyObject(request);
}
}
catch (Exception e)
{
throw new StorageException(string.Format("Failed to copy object. SourceUrl: {0}, DestinationUrl: {1}", sourceUri, destinationUri), e);
}
}
示例2: Copy
/// <summary>
/// Copies the source content to the specified destination on the remote blob storage.
/// </summary>
/// <param name="source">Descriptor of the source item on the remote blob storage.</param>
/// <param name="destination">Descriptor of the destination item on the remote blob storage.</param>
public override void Copy(IBlobContentLocation source, IBlobContentLocation destination)
{
var request = new CopyObjectRequest()
.WithSourceBucket(this.bucketName).WithSourceKey(source.FilePath)
.WithDestinationBucket(this.bucketName).WithDestinationKey(destination.FilePath);
transferUtility.S3Client.CopyObject(request);
}
示例3: CopyFile
public override void CopyFile(string fromBin, string toBin, string fileName)
{
CopyObjectRequest request = new CopyObjectRequest();
request.SourceBucket = fromBin;
request.DestinationBucket = toBin;
request.SourceKey = fileName;
request.DestinationKey = fileName;
CopyObjectResponse response = client.CopyObject(request);
}
示例4: CopyFile
public static void CopyFile(AmazonS3 s3Client, string sourcekey, string targetkey)
{
String destinationPath = targetkey;
CopyObjectRequest request = new CopyObjectRequest()
{
SourceBucket = BUCKET_NAME,
SourceKey = sourcekey,
DestinationBucket = BUCKET_NAME,
DestinationKey = targetkey
};
CopyObjectResponse response = s3Client.CopyObject(request);
}
示例5: CopyFile
/// <summary>
/// The copy file.
/// </summary>
/// <param name="awsAccessKey">
/// The AWS access key.
/// </param>
/// <param name="awsSecretKey">
/// The AWS secret key.
/// </param>
/// <param name="sourceBucket">
/// The source bucket.
/// </param>
/// <param name="sourceKey">
/// The source key.
/// </param>
/// <param name="destinationBucket">
/// The destination bucket.
/// </param>
/// <param name="destinationKey">
/// The destination key.
/// </param>
public static void CopyFile(string awsAccessKey, string awsSecretKey, string sourceBucket, string sourceKey, string destinationBucket, string destinationKey)
{
using (var amazonClient = AWSClientFactory.CreateAmazonS3Client(awsAccessKey, awsSecretKey))
{
var copyRequest = new CopyObjectRequest { CannedACL = S3CannedACL.PublicRead };
copyRequest.WithSourceBucket(sourceBucket);
copyRequest.WithSourceKey(sourceKey);
copyRequest.WithDestinationBucket(destinationBucket);
copyRequest.WithDestinationKey(destinationKey);
amazonClient.CopyObject(copyRequest);
}
}
示例6: Copy
/// <summary>
/// Copies the source content to the specified destination on the remote blob storage.
/// </summary>
/// <param name="source">Descriptor of the source item on the remote blob storage.</param>
/// <param name="destination">Descriptor of the destination item on the remote blob storage.</param>
public override void Copy(IBlobContentLocation source, IBlobContentLocation destination)
{
var request = new CopyObjectRequest()
{
SourceBucket = this.bucketName,
SourceKey = source.FilePath,
DestinationBucket = this.bucketName,
DestinationKey = destination.FilePath,
CannedACL = S3CannedACL.PublicRead
};
transferUtility.S3Client.CopyObject(request);
}
示例7: Copy
public void Copy(string copyFrom, string copyTo)
{
try
{
var copyRequest = new CopyObjectRequest().WithSourceBucket(this._bucketName).WithDestinationBucket(this._bucketName).WithSourceKey(copyFrom).WithDestinationKey(copyTo).WithCannedACL(S3CannedACL.PublicReadWrite);
this._client.CopyObject(copyRequest);
}
catch (Exception ex)
{
Log.Error(string.Format("Cannot copy file from {0} to {1}. Debug message: {2}", copyFrom, copyTo, ex.Message));
return;
}
}
示例8: CopyFile
public void CopyFile(string srcDomain, string srcPath, string destDomain, string destPath)
{
var srcKey = GetKey(_srcTenant, _srcModuleConfiguration.Name, srcDomain, srcPath);
var destKey = GetKey(_destTenant, _destModuleConfiguration.Name, destDomain, destPath);
using (var s3 = GetS3Client())
{
var copyRequest = new CopyObjectRequest{
SourceBucket = _srcBucket,
SourceKey = srcKey,
DestinationBucket = _destBucket,
DestinationKey = destKey,
CannedACL = GetDestDomainAcl(destDomain),
Directive = S3MetadataDirective.REPLACE,
ServerSideEncryptionMethod = ServerSideEncryptionMethod.AES256
};
s3.CopyObject(copyRequest);
}
}
示例9: SetObjectStorageClass
/// <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(string bucketName, string key, string version, S3StorageClass sClass, AmazonS3 s3Client)
{
if (sClass > S3StorageClass.ReducedRedundancy ||
sClass < S3StorageClass.Standard)
{
throw new ArgumentException("Invalid value specified for storage class.");
}
if (null == s3Client)
{
throw new ArgumentNullException("s3Client", "Please specify an S3 Client to make service requests.");
}
// Get the existing ACL of the object
GetACLRequest getACLRequest = new GetACLRequest();
getACLRequest.BucketName = bucketName;
getACLRequest.Key = key;
if(version != null)
getACLRequest.VersionId = version;
GetACLResponse getACLResponse = s3Client.GetACL(getACLRequest);
// Set the storage class on the object
CopyObjectRequest copyRequest = new CopyObjectRequest();
copyRequest.SourceBucket = copyRequest.DestinationBucket = bucketName;
copyRequest.SourceKey = copyRequest.DestinationKey = key;
if (version != null)
copyRequest.SourceVersionId = version;
copyRequest.StorageClass = sClass;
// The copyRequest's Metadata directive is COPY by default
CopyObjectResponse copyResponse = s3Client.CopyObject(copyRequest);
// Set the object's original ACL back onto it because a COPY
// operation resets the ACL on the destination object.
SetACLRequest setACLRequest = new SetACLRequest();
setACLRequest.BucketName = bucketName;
setACLRequest.Key = key;
if (version != null)
setACLRequest.VersionId = copyResponse.VersionId;
setACLRequest.ACL = getACLResponse.AccessControlList;
s3Client.SetACL(setACLRequest);
}
示例10: invokeCopyObject
IAsyncResult invokeCopyObject(CopyObjectRequest copyObjectRequest, AsyncCallback callback, object state, bool synchronized)
{
IRequest irequest = new CopyObjectRequestMarshaller().Marshall(copyObjectRequest);
var unmarshaller = CopyObjectResponseUnmarshaller.GetInstance();
AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
Invoke(result);
return result;
}
示例11: 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);
}
示例12: CopyObject
/// <summary>
/// <para>Creates a copy of an object that is already stored in Amazon S3.</para>
/// </summary>
///
/// <param name="copyObjectRequest">Container for the necessary parameters to execute the CopyObject service method on AmazonS3.</param>
///
/// <returns>The response from the CopyObject service method, as returned by AmazonS3.</returns>
///
public CopyObjectResponse CopyObject(CopyObjectRequest copyObjectRequest)
{
IAsyncResult asyncResult = invokeCopyObject(copyObjectRequest, null, null, true);
return EndCopyObject(asyncResult);
}
示例13: BeginCopyObject
/// <summary>
/// Initiates the asynchronous execution of the CopyObject operation.
/// <seealso cref="Amazon.S3.IAmazonS3.CopyObject"/>
/// </summary>
///
/// <param name="copyObjectRequest">Container for the necessary parameters to execute the CopyObject operation on AmazonS3.</param>
/// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
/// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
/// procedure using the AsyncState property.</param>
///
/// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndCopyObject
/// operation.</returns>
public IAsyncResult BeginCopyObject(CopyObjectRequest copyObjectRequest, AsyncCallback callback, object state)
{
return invokeCopyObject(copyObjectRequest, callback, state, false);
}
示例14: Move
public virtual async Task<bool> Move(string oldNamePath, string newNamePath)
{
bool completed = false;
try
{
IAmazonS3 client = GetS3Client();
CopyObjectRequest request = new CopyObjectRequest()
{
SourceBucket = Settings.BucketName,
SourceKey = oldNamePath,
DestinationBucket = Settings.BucketName,
DestinationKey = newNamePath,
CannedACL = S3CannedACL.PublicRead
};
CopyObjectResponse response = await client.CopyObjectAsync(request);
DeleteObjectRequest deleteRequest = new DeleteObjectRequest()
{
BucketName = request.SourceBucket,
Key = request.SourceKey
};
DeleteObjectResponse deleteResponse = await client.DeleteObjectAsync(deleteRequest);
completed = true;
}
catch (AmazonS3Exception ex)
{
_logger.Exception(ex);
}
return completed;
}
示例15: ProcessRecord
protected override void ProcessRecord()
{
AmazonS3 client = base.GetClient();
Amazon.S3.Model.CopyObjectRequest request = new Amazon.S3.Model.CopyObjectRequest();
request.SourceBucket = this._SourceBucket;
request.SourceKey = this._SourceKey;
request.DestinationBucket = this._DestinationBucket;
request.DestinationKey = this._DestinationKey;
request.ContentType = this._ContentType;
request.ETagToMatch = this._ETagToMatch;
request.ETagToNotMatch = this._ETagToNotMatch;
request.ModifiedSinceDate = this._ModifiedSinceDate;
request.UnmodifiedSinceDate = this._UnmodifiedSinceDate;
request.Timeout = this._Timeout;
request.SourceVersionId = this._SourceVersionId;
Amazon.S3.Model.CopyObjectResponse response = client.CopyObject(request);
}