Fix boto3 S3 upload issue
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
.env
|
.env
|
||||||
__pycache__
|
__pycache__
|
||||||
.vscode
|
.vscode
|
||||||
|
.idea
|
||||||
@@ -63,7 +63,8 @@ def load_latest_statuses(url, token, limit):
|
|||||||
raise Exception('Failed to contact Mastodon', response.text)
|
raise Exception('Failed to contact Mastodon', response.text)
|
||||||
return json.loads(response.text)
|
return json.loads(response.text)
|
||||||
|
|
||||||
def convertToHTML(statuses):
|
|
||||||
|
def convertToHTML(statuses) -> str:
|
||||||
css_file = Path(__file__).parent / '../resources/embed.css'
|
css_file = Path(__file__).parent / '../resources/embed.css'
|
||||||
with css_file.open('r') as css:
|
with css_file.open('r') as css:
|
||||||
doc, tag, text = Doc().tagtext()
|
doc, tag, text = Doc().tagtext()
|
||||||
@@ -96,7 +97,8 @@ def convertToHTML(statuses):
|
|||||||
|
|
||||||
return indent(doc.getvalue())
|
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')
|
s3 = boto3.resource('s3')
|
||||||
object = s3.Object(bucket, key) # type: ignore
|
s3_object = s3.Object(bucket, key)
|
||||||
object.put(Body=content, ACL='public-read', ContentType='text/html')
|
s3_object.put(Body=content.encode("utf-8"), ACL='public-read', ContentType='text/html')
|
||||||
@@ -2,7 +2,7 @@ fastapi[standard]==0.113.0
|
|||||||
pydantic==2.8.0
|
pydantic==2.8.0
|
||||||
pydantic-settings==2.12.0
|
pydantic-settings==2.12.0
|
||||||
requests==2.32.3
|
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
|
yattag==1.16.1
|
||||||
timeago==1.0.16
|
timeago==1.0.16
|
||||||
certifi==2024.12.14
|
certifi==2024.12.14
|
||||||
|
|||||||
Reference in New Issue
Block a user