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

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')