Python Amazon Boto S3正在进行了_restore错误



我正在使用boto S3软件包查看我的存储桶的所有内容。如果我做这样的事情

bucket = s3.get_bucket('my_bucket_name')
for k in bucket:
  print k.ongoing_restore

上面的摘要对于所有对象都不会输出。但是,如果我得到特定键的使用:

k = bucket.get_key('my_key')
k.ongoing_restore

然后,我得到了真实的输出。由于某种原因,该值在第一组代码中无法正确设置,也无法弄清楚原因。任何帮助!

我无法重现您的情况。

您通常可以使用.__dict__进行调试。

这是我的输出:

>>> import boto
>>> s3=boto.connect_s3()
>>> bucket = s3.get_bucket('my-bucket')
>>> for k in bucket:
...   print k.ongoing_restore
... 
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
None
>>> k = bucket.get_key('foo.zip')
>>> k.ongoing_restore
>>> k.__dict__
{'content_length': '234', 'encrypted': None, 'resp': None, 'ongoing_restore': None, 'source_version_id': None, 'content_language': None, '_storage_class': None, 'owner': None, 'filename': None, 'size': 234, 'delete_marker': False, 'etag': '"..."', 'content_encoding': None, 'content_md5': None, 'content_disposition': None, 'cache_control': None, 'metadata': {}, 'expires': None, 'version_id': None, 'x_robots_tag': None, 'last_modified': 'Sun, 06 Aug 2017 03:23:22 GMT', 'content_type': 'application/json', 'date': 'Mon, 28 Aug 2017 22:40:25 GMT', 'path': None, 'is_latest': False, 'local_hashes': {}, 'name': 'foo.zip', 'bucket': <Bucket: my-bucket>, 'expiry_date': None, 'mode': None}
>>> 

我也面临同一问题。

通过使用get_key,它可以正常工作(如下片段中提到)

   conn = get_s3_conn()
   print conn
   buc = get_bucket(conn, buc_name)
   print buc
   for key in buc.list(prefix='class-recordings/'):
       print '----'
       print key.ongoing_restore  #prints None
       k = buc.get_key(key)
       print k.ongoing_restore  #prints True

相关内容

最新更新