Dims
Dims

Reputation: 50989

How to read not my own bucket with python and boto3?

I know bucket name, I have access to it, I can browse it by web and by awscli.

How access it by Python's boto3? All examples assume accessing my own buckets:

import boto3
s3 = boto3.resource('s3')
for bucket in s3.buckets.all():
    print(bucket.name)

How to reach other's bucket?

Upvotes: 1

Views: 51

Answers (1)

gipsy
gipsy

Reputation: 3859

If you have access to someone else's bucket and you know the name of that bucket you can access it like

import boto3

s3 = boto3.resource('s3')
bucket = s3.Bucket('some-bucket-i-have-access-to')
for obj in bucket.objects.all():
    print(obj.key)

Upvotes: 2

Related Questions