Skip to content

Commit 9de2326

Browse files
feat: add more cli options (#294)
1 parent 1ac72a0 commit 9de2326

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/cli/app/client.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import httpx
77
from tqdm import tqdm
88

9+
from app.settings import settings
910
from app.builder.urls import UrlBuilder
1011

1112
# Stream in 8 MiB chunks (matches S3 multipart minimum)
@@ -68,14 +69,27 @@ async def upload_file(
6869
self,
6970
file_path: Path,
7071
filename: str | None = None,
71-
expire_after_n_download: int = 1,
72-
expire_after: int = 86400,
72+
expire_after_n_download: int | None = None,
73+
expire_after: int | None = None,
7374
timeout: Optional[httpx.Timeout] = None,
7475
) -> dict:
7576
"""
7677
Stream-upload *file_path* to ``POST /upload`` on the backend.
7778
Returns the JSON response (contains the download key).
7879
"""
80+
if expire_after_n_download is None:
81+
expire_after_n_download = settings.EXPIRE_AFTER_N_DOWNLOAD
82+
83+
if expire_after is None:
84+
expire_after = settings.EXPIRE_AFTER
85+
86+
if expire_after_n_download is None or expire_after is None:
87+
config = await self.get_config()
88+
if expire_after_n_download is None:
89+
expire_after_n_download = config["default_number_of_downloads"]
90+
if expire_after is None:
91+
expire_after = config["default_expiry"]
92+
7993
upload_url = self.urls.upload_url()
8094
display_name = filename or file_path.name
8195
file_size = file_path.stat().st_size

src/cli/app/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
class Settings(BaseSettings):
55
INSTANCE_URL: str | None = None
6+
EXPIRE_AFTER_N_DOWNLOAD: int | None = None
7+
EXPIRE_AFTER: int | None = None
68

79
model_config = SettingsConfigDict(env_prefix="CHITHI_")
810

0 commit comments

Comments
 (0)