Spaces:
Sleeping
Sleeping
File size: 467 Bytes
aa84f48 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 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
|