Skip to content

Commit

Permalink
Allow public minio host
Browse files Browse the repository at this point in the history
  • Loading branch information
vanatteveldt committed May 28, 2024
1 parent b2c3664 commit c5ee347
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions amcat4/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Settings(BaseSettings):
),
] = None

public_minio_host: Annotated[str | None, Field()] = None
minio_host: Annotated[str | None, Field()] = None
minio_tls: Annotated[bool, Field()] = False
minio_access_key: Annotated[str | None, Field()] = None
Expand Down
5 changes: 4 additions & 1 deletion amcat4/multimedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def presigned_post(index: str, key_prefix: str = "", days_valid=1):
bucket = get_bucket(minio, index)
policy = PostPolicy(bucket, expiration=datetime.datetime.now() + datetime.timedelta(days=days_valid))
policy.add_starts_with_condition("key", key_prefix)
url = f"http{'s' if get_settings().minio_tls else ''}://{get_settings().minio_host}/{bucket}"
minio_host = (
get_settings().public_minio_host or f"http{'s' if get_settings().minio_tls else ''}://{get_settings().minio_host}"
)
url = f"{minio_host}/{bucket}"
return url, minio.presigned_post_policy(policy)


Expand Down

0 comments on commit c5ee347

Please sign in to comment.