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?
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')
In this case, you can use the IPyFS libraries in python.
This is IPFS example URL: https://github.com/837477/IPyFS/tree/dev/examples/nft_image_uploader
You can easily upload your nft images. In the example, you should be setting your environments.
if __name__ == "__main__":
nftmu = NFTMetadataUploader(
host="http://localhost",
port=5001,
metadata_folder="metadata",
images_folder="images",
ipfs_folder="test01",
network_interval_seconds=0.03)
nftmu.check_folders()
nftmu.upload()
print("Done")
Maybe you can catch the necessary value in the code.