I'm trying to do something that might not be possible, but is not apparently so in the documentation. Essentially, I want to set the contents of an s3.key.Key using a different s3.key.Key using the set_contents_from_file method. It reports the following error:
'Key' object has no attribute 'tell'
Here is some code that reproduces the issue.
import boto
from boto.s3.key import Key
s3 = boto.connect_s3()
b = s3.get_bucket("XXXXXX")
ef = b.get_key("figures/test-figure.png") ## this file exists in b.
In [4]: ef.exists()
Out[4]: True
nk = Key(b, "my-new-key.png")
nk.set_contents_from_file(ef)
in set_contents_from_file(self, fp, headers, replace, cb, num_cb, policy, md5, reduced_redundancy, query_args, encrypt_key, size, rewind)
1222 # programs remain that assume the older auto-rewind interface.
1223 if not isinstance(fp, KeyFile):
-> 1224 spos = fp.tell()
1225 fp.seek(0, os.SEEK_END)
1226 if fp.tell() == spos:
AttributeError: 'Key' object has no attribute 'tell'
I've tried to call: 'ef.open_read()' first, but nothing really seems to affect the behavior. I am using:
boto==2.38.0
botocore==1.2.0
Aucun commentaire:
Enregistrer un commentaire