update: uploads
This commit is contained in:
@@ -18,3 +18,14 @@ def save_upload(upload_file: UploadFile) -> Path:
|
||||
with target_path.open("wb") as buffer:
|
||||
shutil.copyfileobj(upload_file.file, buffer)
|
||||
return target_path
|
||||
|
||||
|
||||
def save_upload_for_job(job_id: int, seq: int, upload_file: UploadFile) -> Path:
|
||||
"""Save file with unique path under upload_dir/job_id/ to avoid overwrites."""
|
||||
base = ensure_upload_dir() / str(job_id)
|
||||
base.mkdir(parents=True, exist_ok=True)
|
||||
name = upload_file.filename or "file"
|
||||
target_path = base / f"{seq}_{name}"
|
||||
with target_path.open("wb") as buffer:
|
||||
shutil.copyfileobj(upload_file.file, buffer)
|
||||
return target_path
|
||||
|
||||
Reference in New Issue
Block a user