arcee123
arcee123

Reputation: 243

using boto3 to get file list and download files

I was given this s3 url: s3://file.share.external.bdex.com/Offrs

In this url is a battery of files I need to download.

I have this code:

import boto3

s3_client = boto3.client('s3',
                      aws_access_key_id='<<ACCESS KEY>>',
                      aws_secret_access_key='<<SECRET_ACCESS_KEY>>'
                      )
object_listing = s3_client.list_objects_v2(Bucket='file.share.external.bdex.com/Offrs',
                                    Prefix='')

print(object_listing)

I have tried:

Bucket='file.share.external.bdex.com', Prefix='Offrs'
Bucket='s3://file.share.external.bdex.com/Offrs/'
Bucket='file.share.external.bdx.com/Offrs', Prefix='Offrs'

and several other configurations, all saying I'm not following the regex. due to the slash, or not found.

What am I missing?

Thank you.

Upvotes: 0

Views: 163

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270104

Bucket = 'file.share.external.bdx.com'
Prefix = 'Offrs/'

You can test your access permissions via the AWS CLI:

aws s3 ls s3://file.share.external.bdex.com/Offrs/

Upvotes: 1

Related Questions