Skip to content

Commit

Permalink
Test image buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
liraymond04 committed Dec 11, 2024
1 parent 406f37d commit 0c0600d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/update-buckets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: List all changed image files
if: steps.changed-image-files.outputs.any_changed == 'true'
run: |
IFS=$',' read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-image-files.outputs.modified_files }}"
IFS=$',' read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-image-files.outputs.all_modified_files }}"
for file in "${MODIFIED_FILES_ARRAY[@]}"; do
echo $file
done
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-supabase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: List all changed files markdown files
if: steps.changed-markdown-files.outputs.any_changed == 'true'
run: |
IFS=$',' read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-markdown-files.outputs.modified_files }}"
IFS=$',' read -a MODIFIED_FILES_ARRAY <<< "${{ steps.changed-markdown-files.outputs.all_modified_files }}"
for file in "${MODIFIED_FILES_ARRAY[@]}"; do
echo $file
done
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 15 additions & 2 deletions scripts/update_buckets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import logging
import sys
import mimetypes

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
Expand All @@ -13,6 +14,10 @@

supabase: Client = create_client(SUPABASE_URL, API_KEY)

def get_content_type(file_path):
content_type, _ = mimetypes.guess_type(file_path)
return content_type

def get_added_files_from_env():
try:
added_files_env = os.getenv("ADDED_IMAGE_FILES")
Expand Down Expand Up @@ -70,7 +75,11 @@ def update_image(file):
_ = supabase.storage.from_("images").upload(
file=f,
path=file,
file_options={"cache-control": "3600", "upsert": "true"},
file_options={
"content-type": get_content_type(file) or "text/plain;charset=UTF-8",
"cache-control": "3600",
"upsert": "true"
},
)
logger.info(f"Successfully updated {file}")
except Exception as e:
Expand All @@ -83,7 +92,11 @@ def create_image(file):
_ = supabase.storage.from_("images").upload(
file=f,
path=file,
file_options={"cache-control": "3600", "upsert": "false"},
file_options={
"content-type": get_content_type(file) or "text/plain;charset=UTF-8",
"cache-control": "3600",
"upsert": "false"
},
)
logger.info(f"Successfully created {file}")
except Exception as e:
Expand Down

0 comments on commit 0c0600d

Please sign in to comment.