Skip to content

Instantly share code, notes, and snippets.

View alexbooth's full-sized avatar
😄
¯\_(ツ)_/¯

Alexander Booth alexbooth

😄
¯\_(ツ)_/¯
  • San Francisco, California
View GitHub Profile
@alexbooth
alexbooth / aws_s3.py
Last active October 23, 2021 17:50
Python boto3 + s3
import boto3
def read_filesize_from_s3(bucket, filename):
return bucket.Object(filename).content_length
def list_files(bucket):
for i, obj in enumerate(bucket.objects.all()):
filename = obj.key
filesize = read_filesize_from_s3(bucket, filename)
print(f"[File {i}] [{filesize} bytes] {filename}")