I use AWSSDK for .Net and my code for copy file is:
我使用AWSSDK用于.Net,我的代码用于复制文件:
CopyObjectRequest request = new CopyObjectRequest()
{
SourceBucket = _bucketName,
SourceKey = sourceObjectKey,
DestinationBucket = _bucketName,
DestinationKey = targetObjectKey
};
CopyObjectResponse response = amazonS3Client.CopyObject(request);
The code work perfect for normal files but when i tried to copy file with file name like 'mage...' it getting the following error message:
该代码适用于普通文件,但当我尝试复制文件名如“mage ...”的文件时,它收到以下错误消息:
The request signature we calculated does not match the signature you provided. Check your key and signing method.
我们计算的请求签名与您提供的签名不匹配。检查您的密钥和签名方法。
Is there any way to copy object for that type of files?
有没有办法复制该类型文件的对象?
1 个解决方案
#1
1
I used the following C# code to copy files between S3 folders .
我使用以下C#代码在S3文件夹之间复制文件。
AmazonS3Config cfg = new AmazonS3Config();
cfg.RegionEndpoint = Amazon.RegionEndpoint.EUCentral1;//my bucket has this Region
string bucketName = "your bucket";
AmazonS3Client s3Client = new AmazonS3Client("your access key", "your secret key", cfg);
S3FileInfo sourceFile = new S3FileInfo(s3Client, bucketName, "FolderNameUniTest179/Test.test.test.pdf");
S3DirectoryInfo targetDir = new S3DirectoryInfo(s3Client, bucketName, "Test");
sourceFile.CopyTo(targetDir);
S3FileInfo sourceFile2 = new S3FileInfo(s3Client, bucketName, "FolderNameUniTest179/Test...pdf");
sourceFile2.CopyTo(targetDir);
I am using amazon AWSSDK.Core and AWSSDK.S3 version 3.1.0.0 for .net 3.5. I hope it can help you.
我使用amazon AWSSDK.Core和AWSSDK.S3版本3.1.0.0 for .net 3.5。我希望它可以帮到你。