File size: 727 Bytes
de74fd4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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