Spaces:
Sleeping
Sleeping
| import requests | |
| import os | |
| import tempfile | |
| from pathlib import Path | |
| from consts import DEFAULT_API_URL | |
| def download_files(task_id, file_name): | |
| url = f'{DEFAULT_API_URL}/files/{task_id}' | |
| response = requests.get(url, timeout=15) | |
| tmp_dir = Path(tempfile.gettempdir()) / "project_files" | |
| tmp_dir.mkdir(exist_ok=True) | |
| filepath = os.path.join(tmp_dir, file_name) | |
| with open(filepath, "wb") as f: | |
| f.write(response.content) | |
| return filepath | |