From 700cdfcb4d9b76e9adfab32ea13fc4b9693bca0f Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 9 May 2025 22:20:21 -0700 Subject: fix: html upload content type and indentation --- nijitrack.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/nijitrack.py b/nijitrack.py index 32f9d0b..a1a55ea 100644 --- a/nijitrack.py +++ b/nijitrack.py @@ -159,7 +159,7 @@ def uploadFileToBucketB2(filepath: str) -> bool: print(e) return False -def uploadFileToBucketR2(filepath: str) -> bool: +def uploadFileToBucketR2(filepath: str, content_type: str = "application/json") -> bool: import boto3 account_id = os.environ.get("R2_ACCOUNT_ID") access_key = os.environ.get("R2_ACCESS_KEY") @@ -176,7 +176,7 @@ def uploadFileToBucketR2(filepath: str) -> bool: s3.Bucket(bucket_name).upload_fileobj( Fileobj=f, Key=filepath, - ExtraArgs={"ContentType": "application/json"} + ExtraArgs={"ContentType": content_type} ) print("Successfully uploaded", filepath, "to R2") return True @@ -279,12 +279,12 @@ if __name__ == "__main__": if args.uploadGraph: if upstream_bucket is None: print("Tried to upload graph but no remote source has been specified. Skipping....") - match upstream_bucket: - case BucketType.B2: - uploadFileToBucketB2("index.html") - case BucketType.R2: - uploadFileToBucketR2("index.html") - + exit(1) + match upstream_bucket: + case BucketType.B2: + uploadFileToBucketB2("index.html") + case BucketType.R2: + uploadFileToBucketR2("index.html", content_type="text/html; charset=utf-8") if args.uploadRoutes: if upstream_bucket is None: print("Tried to upload routes but no remote source has been specified. Skipping....") -- cgit v1.2.3