code-review-agent / src /utils /file_utils.py
3v324v23's picture
code agent
e1d6e8a
import os
from pathlib import Path
def save_upload_temp(upload_file, dest_dir: str = ".tmp_uploads") -> str:
Path(dest_dir).mkdir(parents=True, exist_ok=True)
filename = upload_file.filename
dest_path = os.path.join(dest_dir, filename)
with open(dest_path, "wb") as f:
f.write(upload_file.file.read())
return dest_path
def read_file_text(path: str) -> str:
with open(path, "r", encoding="utf-8", errors="ignore") as f:
return f.read()