Spaces:
Build error
Build error
Download utils/file_utils.py from prashantpatil3299/ProjectLensAI: direct link, hf CLI and curl.
- Browser
- Download file 519 Bytes
-
https://huggingface.co/spaces/prashantpatil3299/ProjectLensAI/resolve/main/utils/file_utils.py
- Command line
-
hf download hf://spaces/prashantpatil3299/ProjectLensAI/utils/file_utils.py
-
curl -L -o file_utils.py https://huggingface.co/spaces/prashantpatil3299/ProjectLensAI/resolve/main/utils/file_utils.py
519 Bytes
| import os | |
| import shutil | |
| import tempfile | |
| def save_uploaded_file(uploaded_path: str) -> str: | |
| temp_dir = tempfile.mkdtemp() | |
| filename = os.path.basename(uploaded_path) | |
| new_path = os.path.join(temp_dir, filename) | |
| shutil.copy(uploaded_path, new_path) | |
| return new_path | |
| def read_text_file(file_path: str) -> str: | |
| try: | |
| with open(file_path, "r", encoding="utf-8", errors="ignore") as f: | |
| return f.read() | |
| except Exception as e: | |
| return f"Could not read text file: {str(e)}" |