2

I need to copy from a publicly accessible resource on an AWS S3 bucket to a private S3 bucket while knowing the private bucket configuration(such as secretkey, accesskey, etc) using nodeJS AWS SDK.

My thoughts are using http.get or request to get the content of the public object and then simply use regular S3.upload() function, but maybe there is a more efficient way.

Thanks

Ron Merkin
  • 21
  • 2
  • 1
    Take a look at the copyObject method (http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#copyObject-property). – jarmod Oct 08 '17 at 14:43
  • If I'm correct, this will trigger an authorization error because you can't put the credentials of the destination bucket – Michael Lumbroso Oct 08 '17 at 14:57
  • Check the following Stackoverflow question/answers https://stackoverflow.com/questions/30959251/how-to-copy-move-all-objects-in-amazon-s3-from-one-prefix-to-other-using-the-aws – Ashan Oct 08 '17 at 15:40
  • @MichaelLumbroso a copy-object request is sent to the destination bucket, not the source. The destination pulls the content across, internal to S3. You use the destination credentials to send the request. – Michael - sqlbot Oct 08 '17 at 20:08
  • @Michael-sqlbot The copy object triggers authentication error because you will pass authentication credentials to the request and those credentials don't have access to the source bucket. – Arpit Solanki Feb 22 '19 at 12:00
  • @ArpitSolanki the question refers to the source bucket as "public." – Michael - sqlbot Feb 22 '19 at 15:13
  • @Michael-sqlbot Yes. Even with a public bucket if you provide credentials it will throw an error because policies will be checked against those credentials and those credentials don't have access to that bucket. Only if you try it as anonymous user it will succeed – Arpit Solanki Feb 22 '19 at 18:09

0 Answers0