Duplicate file in Amazon S3

I am trying to duplicate a file from a bucket into another, but I can’t stitch to see the new file in the destination container.

I get no errors at all ...

Request:

enter image description here

Answer:

<?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>&quot;a5f9084078981b64737b57dbf1735fcf&quot;</ETag> </CopyObjectResult> 

But I keep checking the last modified date on S3, and I can not find any information about this new file, or I can access it directly

http://jk-v20.s3.amazonaws.com/PublicFiles/3ff28e21-4801-47c6-a6d0-e370706d303f_Content_Favicon.ico

What am I doing wrong?


Method:

 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; } } 
+7
source share
3 answers

http://jk-v20.s3.amazonaws.com//PublicFiles/3ff28e21-4801-47c6-a6d0-e370706d303f_Content_Favicon.ico

Where is the file located. (Note the double slash. // ..) If you click this URL, you will see the ico file. So this is due to the leading slash, which can be automatically added by your toolbox.

+6
source

Can you post a request (with headers) captured by something like a violinist?

docs indicates that the original path should start with a slash (i.e. fully qualified), have you tried this?

 x-amz-copy-source: /source_bucket/sourceObject 

Maybe the framework does this for you, but your destination has a leading slash, or maybe ...

0
source

The code looks right, I use something similar in my working application.

It might be useful to enable server access logging on your s3 buckets to understand what's going on behind the scenes - http://docs.amazonwebservices.com/AmazonS3/latest/dev/ServerLogs.html .

0
source

All Articles