我試圖將文件從一個存儲桶複製到另一個存儲器,但無法在目標存儲桶中看到新文件。亞馬遜S3中的重複文件
我得到沒有錯誤在所有...
請求:
響應:
<?xml version="1.0" encoding="UTF-8"?>
<CopyObjectResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<LastModified>2012-04-08T11:26:36.000Z</LastModified
<ETag>"a5f9084078981b64737b57dbf1735fcf"</ETag>
</CopyObjectResult>
,但我一直檢查最後修改日期 S3上,我不能找到有關這個新文件的任何信息,無論是我可以直接訪問它
http://jk-v20.s3.amazonaws.com/PublicFiles/3ff28e21-4801-47c6-a6d0-e370706d303f_Content_Favicon.ico
我在做什麼錯?
方法:
public void DuplicateFileInCloud(string original, string destination)
{
try
{
CopyObjectRequest request = new CopyObjectRequest();
if (original.StartsWith("http"))
{
// could be from other bucket, URL will show all data
// example: http://jk-v30.s3.amazonaws.com/PredefinedFiles/Favicons/002.ico
string bucket = getBucketNameFromUrl(original), // jk-v30
key = getKeyFromUrl(original); // PredefinedFiles/Favicons/002.ico
request.WithSourceBucket(bucket);
request.WithSourceKey(key);
}
else
{
// same bucket: copy/paste operation
request.WithSourceBucket(this.bucketName);
request.WithSourceKey(original);
}
request.WithDestinationBucket(this.bucketName);
request.WithDestinationKey(destination);
request.CannedACL = S3CannedACL.PublicRead;
using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(this.accessKey, this.secretAccessKey))
{
S3Response response = client.CopyObject(request);
response.Dispose();
}
}
catch (AmazonS3Exception s3Exception)
{
throw s3Exception;
}
}
如果你沒有檢查官方幫助,它可能是值得的,有完整的例子:http://docs.amazonwebservices.com/AmazonS3/latest/dev/CopyingObjectUsingNetSDK.html – 2012-04-15 16:07:42