'errore while Uploading files on IPFS with python

I'm trying to upload png or json with pinata on ipfs with Python but when i'm run the code i get an error like :

for (k, v) in files:
ValueError: too many values to unpack (expected 2)

I don't know why, i need to upload one file at time. This is my code :

import os
import requests
import typing as tp

path = "./nft_test/"

headers = {        
    'pinata_api_key': "key",
    'pinata_secret_api_key': "secret-key"     
}   

ipfs_url = "https://api.pinata.cloud/pinning/pinFileToIPFS"

for x in os.listdir(path):
        with open(path+x, 'rb') as file  :
            response: requests.Response = requests.post(url=ipfs_url, files=file, headers=headers)
            print(response.json())

Someone can help me plase ? thank you !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source