Last active
December 16, 2020 12:10
-
-
Save 11philip22/0c86058ffe8490087ac3ae3ed2ea082e to your computer and use it in GitHub Desktop.
aws boto3 iterate trough public s3 bucket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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