I am using a scenario where uploading encrypted file to the ipfs, now I wanted it to download and then decrypt. Is there any way to download file using python?
you can use python wrapper over IPFS to interact with IPFS. you can download it from here
https://github.com/ipfs/py-ipfs-api.git
import ipfsapi
api = ipfsapi.connect('127.0.0.1', 5001)
To add a file
new_file = api.add('new.txt')
The response will be like
{'Name': 'new.txt', 'Hash': 'QmWvgsuZkaWxN1iC7GDciEGsAqphmDyCsk3CVHh7XVUUHq', 'Size': '28'}
In order to see the content of file you call
api.cat('QmWvgsuZkaWxN1iC7GDciEGsAqphmDyCsk3CVHh7XVUUHq')
for more can use the documantation https://media.readthedocs.org/pdf/python-ipfs-api/latest/python-ipfs-api.pdf.
Here is the code:
import ipfsApi
api = ipfsApi.Client(host='https://ipfs.infura.io', port=5001)
#OR
#api = ipfsApi.Client(host='http://127.0.0.1', port=5001)
api.get('Qm... Your IPFS Hash')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With