Created
June 5, 2021 23:43
-
-
Save evandiewald/5fb415d66dac0abf1ae9140daa4c139f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import config | |
def pin_to_pinata(file_obj, filename): | |
url = "https://api.pinata.cloud/pinning/pinFileToIPFS" | |
payload = {} | |
files = [ | |
('file', (filename, file_obj, 'image/jpeg')) | |
] | |
headers = { | |
'pinata_api_key': config.PINATA_KEY, | |
'pinata_secret_api_key': config.PINATA_SECRET | |
} | |
response = requests.request("POST", url, headers=headers, data=payload, files=files) | |
return response.json() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment