本文整理汇总了C#中Amazon.S3.Model.CopyObjectRequest类的典型用法代码示例。如果您正苦于以下问题:C# CopyObjectRequest类的具体用法?C# CopyObjectRequest怎么用?C# CopyObjectRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CopyObjectRequest类属于Amazon.S3.Model命名空间,在下文中一共展示了CopyObjectRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:navid60,项目名称:BetterCMS,代码行数:29,代码来源:AmazonS3StorageService.cs
示例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);
}
开发者ID:raydowe,项目名称:amazon-s3-provider,代码行数:13,代码来源:AmazonBlobStorageProvider.cs
示例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);
}
开发者ID:smithydll,项目名称:boxsocial,代码行数:9,代码来源:AmazonS3.cs
示例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);
}
开发者ID:xescrp,项目名称:breinstormin,代码行数:12,代码来源:S3Engine.cs
示例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);
}
}
开发者ID:Naviam,项目名称:Shop-Any-Ware,代码行数:33,代码来源:AmazonS3Helper.cs
示例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);
}
开发者ID:nexuschurch,项目名称:amazon-s3-provider,代码行数:18,代码来源:AmazonBlobStorageProvider.cs
示例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;
}
}
开发者ID:ajuris,项目名称:opensource,代码行数:13,代码来源:AmazonS3Repository.cs
示例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);
}
}
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:20,代码来源:S3CrossModuleTransferUtility.cs
示例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);
}
开发者ID:writeameer,项目名称:AWSSDKForNet-extended,代码行数:51,代码来源:AmazonS3Util.cs
示例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;
}
开发者ID:jeffersonjhunt,项目名称:aws-sdk-net,代码行数:8,代码来源:AmazonS3Client.cs
示例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);
}
开发者ID:SmartFire,项目名称:JG.Orchard.AmazonS3Storage,代码行数:11,代码来源:S3StorageProvider.cs
示例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);
}
开发者ID:jeffersonjhunt,项目名称:aws-sdk-net,代码行数:13,代码来源:AmazonS3Client.cs
示例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);
}
开发者ID:jeffersonjhunt,项目名称:aws-sdk-net,代码行数:16,代码来源:AmazonS3Client.cs
示例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;
}
开发者ID:RodionKulin,项目名称:ContentManagementBackend,代码行数:35,代码来源:AmazonFileStorage.cs
示例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);
}
开发者ID:ksikes,项目名称:Amazon.Powershell,代码行数:17,代码来源:CopyObjectCmdlet.cs
示例16: ReplaceAdImages
public void ReplaceAdImages(ref Ad ad, FileName[] filenames)
{
string newFileName = "";
int count = 1;
var id = ad.Id;
var imaa = db.AdImages.Where(x => x.adId.Equals(id)).Count();
count = imaa + 1;
for (int i = 1; i < filenames.Length; i++)
{
IAmazonS3 client;
try
{
using (client = new AmazonS3Client(Amazon.RegionEndpoint.USEast1))
{
GetObjectRequest request = new GetObjectRequest
{
BucketName = _bucketName,
Key = _folderName + filenames[i].fileName
};
using (GetObjectResponse response = client.GetObject(request))
{
string filename = filenames[i].fileName;
if (!System.IO.File.Exists(filename))
{
string extension = System.IO.Path.GetExtension(filenames[i].fileName);
newFileName = ad.Id.ToString() + "_" + count + extension;
client = new AmazonS3Client(Amazon.RegionEndpoint.USEast1);
CopyObjectRequest request1 = new CopyObjectRequest()
{
SourceBucket = _bucketName,
SourceKey = _folderName + filename,
DestinationBucket = _bucketName,
CannedACL = S3CannedACL.PublicRead,//PERMISSION TO FILE PUBLIC ACCESIBLE
DestinationKey = _folderName + newFileName
};
CopyObjectResponse response1 = client.CopyObject(request1);
AdImage image = new AdImage();
image.imageExtension = extension;
image.adId = ad.Id;
db.AdImages.Add(image);
db.SaveChanges();
count++;
DeleteObjectRequest deleteObjectRequest =
new DeleteObjectRequest
{
BucketName = _bucketName,
Key = _folderName + filenames[i].fileName
};
AmazonS3Config config = new AmazonS3Config();
config.ServiceURL = "https://s3.amazonaws.com/";
using (client = Amazon.AWSClientFactory.CreateAmazonS3Client(
_awsAccessKey, _awsSecretKey, config))
{
client.DeleteObject(deleteObjectRequest);
}
}
}
}
}
catch (Exception e)
{
}
}
}
开发者ID:mubasharali,项目名称:myfiles3,代码行数:71,代码来源:ElectronicsController.cs
示例17: RenameFolder
public void RenameFolder(long objectId, string oldObjectName, string newObjectName, string clientDateTime2)
{
var userData = _readOnlyRepository.First<Account>(a => a.EMail == User.Identity.Name);
var fileData = userData.Files.FirstOrDefault(f => f.Id == objectId);
var userFiles = userData.Files.Where(t => t.Url.Contains(fileData.Name));
var clientDate = Convert.ToDateTime(clientDateTime2);
var newFoldUrl = string.IsNullOrEmpty(fileData.Url) || string.IsNullOrWhiteSpace(fileData.Url)
? newObjectName + "/"
: fileData.Url.Replace(oldObjectName, newObjectName) + fileData.Name + "/";
var putFolder = new PutObjectRequest { BucketName = userData.BucketName, Key = newFoldUrl, ContentBody = string.Empty };
AWSClient.PutObject(putFolder);
foreach (var file in userFiles)
{
if (file == null)
continue;
if (file.IsDirectory)
{
RenameFolder(file.Id, oldObjectName, newObjectName, clientDateTime2);
}
else
{
//Copy the object
var newUrl = file.Url.Replace(oldObjectName, newObjectName) + file.Name;
var copyRequest = new CopyObjectRequest
{
SourceBucket = userData.BucketName,
SourceKey = file.Url + file.Name,
DestinationBucket = userData.BucketName,
DestinationKey = newUrl,
CannedACL = S3CannedACL.PublicRead
};
AWSClient.CopyObject(copyRequest);
//Delete the original
var deleteRequest = new DeleteObjectRequest
{
BucketName = userData.BucketName,
Key = file.Url + file.Name
};
AWSClient.DeleteObject(deleteRequest);
file.ModifiedDate = clientDate;
file.Url = file.Url.Replace(oldObjectName, newObjectName);
_writeOnlyRepository.Update(file);
}
}//fin foreach
var deleteFolderRequest = new DeleteObjectRequest
{
BucketName = userData.BucketName,
Key = fileData.Url + fileData.Name + "/"
};
AWSClient.DeleteObject(deleteFolderRequest);
var newFolderUrl = fileData.Url.Replace(oldObjectName, newObjectName);
fileData.Url = newFolderUrl;
_writeOnlyRepository.Update(fileData);
}
开发者ID:Edalzebu,项目名称:MiniDropbox-Programacion4,代码行数:65,代码来源:FilesController.cs
示例18: CopyObjectAsync
/// <summary>
/// Creates a copy of an object that is already stored in Amazon S3.
/// This API is supported only when AWSConfigs.HttpClient is set to AWSConfigs.HttpClientOption.UnityWebRequest, the default value of this configuration option is AWSConfigs.HttpClientOption.UnityWWW
/// </summary>
/// <param name="sourceBucket">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="sourceKey">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="sourceVersionId">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="destinationBucket">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="destinationKey">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
/// <param name="options">
/// 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>The response from the CopyObject service method, as returned by S3.</returns>
public void CopyObjectAsync(string sourceBucket, string sourceKey, string sourceVersionId, string destinationBucket, string destinationKey, AmazonServiceCallback<CopyObjectRequest, CopyObjectResponse> callback, AsyncOptions options = null)
{
var request = new CopyObjectRequest();
request.SourceBucket = sourceBucket;
request.SourceKey = sourceKey;
request.SourceVersionId = sourceVersionId;
request.DestinationBucket = destinationBucket;
request.DestinationKey = destinationKey;
CopyObjectAsync(request, callback, options);
}
开发者ID:aws,项目名称:aws-sdk-net,代码行数:26,代码来源:AmazonS3Client.cs
示例19: Copy
public virtual async Task<bool> Copy(List<string> oldNamePaths, List<string> newNamePaths)
{
bool completed = false;
try
{
IAmazonS3 client = GetS3Client();
List<Task<CopyObjectResponse>> requestTasks = new List<Task<CopyObjectResponse>>();
for (int i = 0; i < oldNamePaths.Count; i++)
{
CopyObjectRequest request = new CopyObjectRequest()
{
SourceBucket = Settings.BucketName,
SourceKey = oldNamePaths[i],
DestinationBucket = Settings.BucketName,
DestinationKey = newNamePaths[i],
CannedACL = S3CannedACL.PublicRead
};
Task<CopyObjectResponse> response = client.CopyObjectAsync(request);
requestTasks.Add(response);
}
CopyObjectResponse[] responses = await Task.WhenAll(requestTasks.ToArray());
completed = true;
}
catch (AmazonS3Exception ex)
{
_logger.Exception(ex);
}
return completed;
}
开发者ID:RodionKulin,项目名称:ContentManagementBackend,代码行数:34,代码来源:AmazonFileStorage.cs
示例20: CopyObjectAsync
/// <summary>
/// Creates a copy of an object that is already stored in Amazon S3.
/// </summary>
/// <param name="sourceBucket">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="sourceKey">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="sourceVersionId">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="destinationBucket">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="destinationKey">A property of CopyObjectRequest used to execute the CopyObject service method.</param>
/// <param name="cancellationToken">
/// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
/// </param>
///
/// <returns>The response from the CopyObject service method, as returned by S3.</returns>
public Task<CopyObjectResponse> CopyObjectAsync(string sourceBucket, string sourceKey, string sourceVersionId, string destinationBucket, string destinationKey, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
{
var request = new CopyObjectRequest();
request.SourceBucket = sourceBucket;
request.SourceKey = sourceKey;
request.SourceVersionId = sourceVersionId;
request.DestinationBucket = destinationBucket;
request.DestinationKey = destinationKey;
return CopyObjectAsync(request, cancellationToken);
}
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:23,代码来源:AmazonS3Client.cs
注:本文中的Amazon.S3.Model.CopyObjectRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论