Spaces:
Sleeping
Sleeping
Download app/utils/file_handler.py from jayansh21/skillsync-backend: direct link, hf CLI and curl.
- Browser
- Download file 593 Bytes
-
https://huggingface.co/spaces/jayansh21/skillsync-backend/resolve/main/app/utils/file_handler.py
- Command line
-
hf download hf://spaces/jayansh21/skillsync-backend/app/utils/file_handler.py
-
curl -L -o file_handler.py https://huggingface.co/spaces/jayansh21/skillsync-backend/resolve/main/app/utils/file_handler.py
593 Bytes
| import os | |
| import shutil | |
| from pathlib import Path | |
| from fastapi import UploadFile | |
| UPLOAD_DIR = Path("uploads") | |
| UPLOAD_DIR.mkdir(exist_ok=True) | |
| class FileHandler: | |
| async def save_upload_file(upload_file: UploadFile) -> str: | |
| try: | |
| file_path = UPLOAD_DIR / upload_file.filename | |
| with file_path.open("wb") as buffer: | |
| shutil.copyfileobj(upload_file.file, buffer) | |
| return str(file_path) | |
| except Exception as e: | |
| # In a real app, log this | |
| print(f"Error saving file: {e}") | |
| raise e | |