我使用AWSSDK用于.Net,我的代码用于复制文件:
CopyObjectRequest request = new CopyObjectRequest()
{
SourceBucket = _bucketName,
SourceKey = sourceObjectKey,
DestinationBucket = _bucketName,
DestinationKey = targetObjectKey
};
CopyObjectResponse response = amazonS3Client.CopyObject(request);
该代码适用于普通文件,但当我尝试使用文件名复制文件时,例如' mage ...'它收到以下错误消息:
The request signature we calculated does not match the signature you provided. Check your key and signing method.
有没有办法复制该类型文件的对象?
答案 0 :(得分:1)
我使用以下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);
我正在使用amazon AWSSDK.Core和AWSSDK.S3版本3.1.0.0 for .net 3.5。我希望它可以帮到你。