Skip to content

Instantly share code, notes, and snippets.

@11philip22
Last active December 16, 2020 12:10
Show Gist options
  • Save 11philip22/0c86058ffe8490087ac3ae3ed2ea082e to your computer and use it in GitHub Desktop.
Save 11philip22/0c86058ffe8490087ac3ae3ed2ea082e to your computer and use it in GitHub Desktop.
aws boto3 iterate trough public s3 bucket
import boto3
from botocore.handlers import disable_signing
from botocore import UNSIGNED
from botocore.client import Config
bucket_name = 'nice try fbi'
s3_client = boto3.client('s3', config=Config(signature_version=UNSIGNED))
s3_resource = boto3.resource('s3')
s3_resource.meta.client.meta.events.register('choose-signer.s3.*', disable_signing)
bucket = s3_resource.Bucket(bucket_name)
for file in bucket.objects.all():
params = {'Bucket': bucket_name, 'Key': file.key}
url = s3_client.generate_presigned_url('get_object', params)
print(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment