Spaces:
No application file
No application file
| from huggingface_hub import HfApi,upload_file,file_exists | |
| def create_repo(): | |
| return None | |
| def file_exists(repo_id,file_name,repo_type): | |
| if file_exists(repo_id, file_name,repo_type): | |
| return f"File:: {file_name} exists in {repo_id}" | |
| else: | |
| return f"File:: {file_name} does not exist in {repo_id}" | |
| def hf_upload(file_obj,repo_file,repo_id,token,repo_type="space") | |
| api=HfApi() | |
| try: | |
| api.upload_file( | |
| path_or_fileobj=file_obj, | |
| path_in_repo=repo_file, | |
| repo_id=repo_id, | |
| token=token, | |
| repo_type=repo_type, | |
| ) | |
| return f"File written to {repo_id}/{repo_file}" | |
| except Exception as e: | |
| return e |