Skip to content

Instantly share code, notes, and snippets.

View awsjk23's full-sized avatar

Jordan Kojouharov awsjk23

  • Amazon Web Services
  • Scottsdale, AZ
View GitHub Profile
@awsjk23
awsjk23 / boto3-gzip.py
Created February 22, 2023 23:43 — forked from tobywf/boto3-gzip.py
GZIP compressing files for S3 uploads with boto3
from io import BytesIO
import gzip
import shutil
def upload_gzipped(bucket, key, fp, compressed_fp=None, content_type='text/plain'):
"""Compress and upload the contents from fp to S3.
If compressed_fp is None, the compression is performed in memory.
"""