|
6 | 6 | import httpx |
7 | 7 | from tqdm import tqdm |
8 | 8 |
|
| 9 | +from app.settings import settings |
9 | 10 | from app.builder.urls import UrlBuilder |
10 | 11 |
|
11 | 12 | # Stream in 8 MiB chunks (matches S3 multipart minimum) |
@@ -68,14 +69,27 @@ async def upload_file( |
68 | 69 | self, |
69 | 70 | file_path: Path, |
70 | 71 | 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, |
73 | 74 | timeout: Optional[httpx.Timeout] = None, |
74 | 75 | ) -> dict: |
75 | 76 | """ |
76 | 77 | Stream-upload *file_path* to ``POST /upload`` on the backend. |
77 | 78 | Returns the JSON response (contains the download key). |
78 | 79 | """ |
| 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 | + |
79 | 93 | upload_url = self.urls.upload_url() |
80 | 94 | display_name = filename or file_path.name |
81 | 95 | file_size = file_path.stat().st_size |
|
0 commit comments