boto / boto

For the latest version of boto, see https://github.com/boto/boto3 -- Python interface to Amazon Web Services
http://docs.pythonboto.org/
Other
6.48k stars 2.26k forks source link

bucket.list() raises 403 when list too long #3006

Open lajarre opened 9 years ago

lajarre commented 9 years ago

This seems really related to the number of keys since I'm able to go around the problem by cutting in chunks.

Heres' the err:

---------------------------------------------------------------------------
S3ResponseError                           Traceback (most recent call last)
<ipython-input-49-cb354284039c> in <module>()
----> 1 for k in bu.list(prefix='media/documents/'):
      2     print k
      3

./lib/python2.7/site-packages/boto/s3/bucketlistresultset.pyc in bucket_lister(bucket, prefix, delimiter, marker, headers, encoding_type)
     32         rs = bucket.get_all_keys(prefix=prefix, marker=marker,
     33                                  delimiter=delimiter, headers=headers,
---> 34                                  encoding_type=encoding_type)
     35         for k in rs:
     36             yield k

./lib/python2.7/site-packages/boto/s3/bucket.pyc in get_all_keys(self, headers, **params)
    470         return self._get_all([('Contents', self.key_class),
    471                               ('CommonPrefixes', Prefix)],
--> 472                              '', headers, **params)
    473
    474     def get_all_versions(self, headers=None, **params):

./lib/python2.7/site-packages/boto/s3/bucket.pyc in _get_all(self, element_map, initial_query_string, headers, **params)
    408         else:
    409             raise self.connection.provider.storage_response_error(
--> 410                 response.status, response.reason, body)
    411
    412     def validate_kwarg_names(self, kwargs, names):

S3ResponseError: S3ResponseError: 403 Forbidden
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message><AWSAccessKeyId....
bcipolli commented 9 years ago

@lajarre how did you cut things into chunks? I'm afraid I may be hitting the same issue.

lajarre commented 9 years ago

@bcipolli Don't remember precisely but I guess I did something using the marker arg like:

k = None
while True:
    try:
        for k in bucket.list(marker=k):
            print k
    except S3ResponseError:
        pass
    else:
        break