简体   繁体   中英

Accessing nested buckets in S3 with Boto3

I know the path of the bucket I want to access /bucket1/bucket2/etc/ but I can't figure out how to access it via boto3.

I can enumerate all buckets starting from the source, but can't get to the bucket I want.

For example I can do:

prod_bucket = s3.Bucket('prod')

But I cannot do:

prod_bucket = s3.Bucket('prod/prod2/')

TIA

There are no nested buckets. You have bucket and objects.

s3 = boto3.client('s3')
object = s3.get_object(Bucket='prod', Key='prod2/..')

Or:

s3 = boto3.resource('s3')
bucket = s3.Bucket('prod')
object = bucket.Object('prod2/..')

See: get_object

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM