Spaces:
Build error
Build error
| from dotenv import load_dotenv | |
| from huggingface_hub import HfApi | |
| load_dotenv() | |
| repo_id = "zaradana/temp_files" | |
| api = HfApi() | |
| def upload_file(file_local_path: str) -> str: | |
| """ | |
| Upload a file to the Hugging Face Hub and return the URL | |
| Args: | |
| file_local_path: The local path to the file | |
| Returns: | |
| The URL of the uploaded file | |
| """ | |
| file_name = file_local_path.split("/")[-1] | |
| api.upload_file( | |
| path_or_fileobj=file_local_path, | |
| path_in_repo=file_name, | |
| repo_id=repo_id, | |
| repo_type="dataset" | |
| ) | |
| file_url = f"https://huggingface.co/datasets/{repo_id}/resolve/main/{file_name}" | |
| return file_url | |