1

I have two s3 buckets, take "srcs3bck" and "dsts3bck", i have a text file in srcs3bck. I tried the answer suggested in StackOverFlow question to copy the source to destination. But when i do i am getting 404 response error, stating my source bucket is not available.

But i tried to get bucket and get all kes. It is displaying the key.

>>> import boto
>>> conn=boto.connect(<credentials>)
>>> src = conn.get_bucket("srcs3bck")
>>> src.get_all_keys()
printing my key list properly.
>>> dst = conn.get_bucket("dsts3bck")
>>>
>>> src.get_all_keys()
[<Key: srcs3bck,Test2.txt>]
>>> 
>>> src.list()
<boto.s3.bucketlistresultset.BucketListResultSet object at 0x03768310>
>>> x=src.list()
>>> for i in x: print i
<Key: srcs3bck,Test2.txt>
>>> for i in x: print i.key
Test2.txt
>>> for i in x: dst.copy_key(i.key,src,i.key)
.......
ignoring other lines
....
S3ResponseError: S3ResponseError: 404 Not Found
<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><BucketName>&lt;Bucket: srcs3bck&gt;</BucketName><RequestId>358C4C2420BB91E9</RequestId><HostId>ws6wagGIZqquStqisfGuYHeMMscmmR2Iu8LL4jCv9KpLBzxieiryI/mRwxwz4aQ=</HostId></Error>
>>>     

What else i need to change on this. I am not sure of what mistake i am doing. Could anyone help me resolving this. Thanks in advance

Community
  • 1
  • 1
Myjab
  • 924
  • 1
  • 7
  • 22

1 Answers1

4

The copy_key method is actually looking for the bucket name, not the bucket object. So try this instead:

for i in x: dst.copy_key(i.key,src.name,i.key)
rumdrums
  • 1,322
  • 2
  • 11
  • 25