import boto3 # Create an S3 client s3 = boto3.client('s3') # Set the name of the S3 bucket and the folder prefix bucket_name = 'my-bucket' folder_prefix = 'path/to/folder/' # Use the S3 client to list the objects in the bucket result = s3.list_objects_v2(Bucket=bucket_name, Prefix=folder_prefix) # Extract the list of files from the response files = [content['Key'] for content in result.get('Contents', [])] # Print the list of files print(files)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter