I followed your tutorial to upload a file on IPFS, but I am not able to fetch it back. It returns me corrupted file, here is my piece of code:
import requests
import json
files = {
‘file’: ‘test.pdf’
}
response = requests.post(
‘https://ipfs.infura.io:5001/api/v0/add’,
files=files,
auth=(
‘key’,
‘secret’)
)
response_ipfs = json.loads(response.text)
params = (
(‘arg’,response_ipfs[‘Hash’]),
)
response = requests.post(‘https://ipfs.infura.io:5001/api/v0/cat’,
params=params,
auth=(‘key’,
‘secret’)
)
with open(‘test2.pdf’, ‘wb’) as f:
f.write(response.content)
Any idea why?