I have been given access to an S3 bucket:
S3 base path : s3://folder1/folder2/*
with an IAM user account:
arn:aws:iam::< Account >:user/< username >
I've tried the following but no luck.
import boto3
client = boto3.client(
's3',
aws_access_key_id='****',
aws_secret_access_key='****'
)
obj1 = client.get_object("folder1/folder2/*") #TypeError
obj2 = boto3.resource("folder1/folder2/*") # DataNotFoundError
Any help regarding this would be appreciated. Thanks!
s3 path consists of bucket and object in the form:
s3://<Bucket>/<Key>
You can use the following expression to split your "s3_key" into bucket and key:
bucket, key = s3_key.split('/',2)[-1].split('/',1)
So to access object from the path s3://folder1/folder2 you would do the following:
import boto3
client = boto3.client('s3')
client.get_object(Bucket='folder1', Key='folder2')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With