Fix boto3 S3 upload issue
All checks were successful
Build & Release / build-docker-image (push) Successful in 1m46s
Build & Release / deploy-to-production (push) Successful in 25s

This commit is contained in:
2026-05-25 20:10:35 +02:00
parent 1382c0748d
commit ad68c75ed3
3 changed files with 9 additions and 6 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
.env
__pycache__
.vscode
.idea

View File

@@ -63,7 +63,8 @@ def load_latest_statuses(url, token, limit):
raise Exception('Failed to contact Mastodon', response.text)
return json.loads(response.text)
def convertToHTML(statuses):
def convertToHTML(statuses) -> str:
css_file = Path(__file__).parent / '../resources/embed.css'
with css_file.open('r') as css:
doc, tag, text = Doc().tagtext()
@@ -96,7 +97,8 @@ def convertToHTML(statuses):
return indent(doc.getvalue())
def uploadToAmazonS3(bucket, key, content):
def uploadToAmazonS3(bucket, key, content:str):
logger.info(f'Uploading embed html to {bucket}/{key}')
s3 = boto3.resource('s3')
object = s3.Object(bucket, key) # type: ignore
object.put(Body=content, ACL='public-read', ContentType='text/html')
s3_object = s3.Object(bucket, key)
s3_object.put(Body=content.encode("utf-8"), ACL='public-read', ContentType='text/html')

View File

@@ -2,7 +2,7 @@ fastapi[standard]==0.113.0
pydantic==2.8.0
pydantic-settings==2.12.0
requests==2.32.3
boto3==1.36.21
boto3==1.35.48 # Note: Upgrading might break boto3 upload with XAmzContentSHA256Mismatch errors
yattag==1.16.1
timeago==1.0.16
certifi==2024.12.14