File size: 847 Bytes
5b94dcd
397d469
5b94dcd
397d469
 
 
 
5b94dcd
 
 
397d469
5b94dcd
 
397d469
5b94dcd
397d469
5b94dcd
 
8fc7ce7
5b94dcd
397d469
5b94dcd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from transformers import HfApi

def upload_file_to_huggingface(file_url, filename, api_token):
    # Download the file from the URL
    response = requests.get(file_url)
    file_content = response.content

    # Initialize the Hugging Face API client
    hf_api = HfApi()
    hf_api.set_access_token(api_token)

    # Upload the file to Hugging Face
    hf_api.upload_file(filename, file_content)

    print(f"File uploaded to Hugging Face as {filename}")

# Replace 'your-api-token' with your actual Hugging Face API token
api_token = '26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'
file_url = 'https://dkstatics-public.digikala.com/digikala-products/26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'
filename = '26c6255b595c4aac4c30f7fa6644c1a726b70972_1694005299.jpg'

upload_file_to_huggingface(file_url, filename, api_token)