(name: str, data: str)
| 6 | s3 = boto3.client('s3', endpoint_url=config.AWS_ENDPOINT_URL_S3) |
| 7 | |
| 8 | def upload(name: str, data: str): |
| 9 | gzip_buffer = BytesIO() |
| 10 | with gzip.GzipFile(mode='wb', fileobj=gzip_buffer) as gzip_file: |
| 11 | gzip_file.write(data.encode('utf-8')) |
| 12 | return s3.put_object( |
| 13 | Bucket=config.BUCKET_NAME, |
| 14 | Key=name, |
| 15 | Body=gzip_buffer.getvalue(), |
| 16 | ContentEncoding='gzip', |
| 17 | ContentType='application/json' |
| 18 | ) |
| 19 | |
| 20 | def download(name: str) -> str: |
| 21 | response = s3.get_object(Bucket=config.BUCKET_NAME, Key=name) |