The ipfsapi API

Let's go back to the API of ipfsapi. We have added a file with IPFS API and received the hash that we use to refer to the content of the file. But if we add a big file, this will be split into many chunks. This is for efficiency purposes.

Let's download quite a big image file from Unsplash. Go to, https://unsplash.com/photos/UBtUB4Qc-_4 to download an image file. The name of the downloaded file is milada-vigerova-1284157-unsplash.jpg. Put this in the same directory as your IPFS Python script files. You could use any image file for this, but make sure its size is at least 1 MB. However, if you use another image file, you should get a different hash.

Create a script named add_image_file.py using the following code block:

Get Hands-On Blockchain for Python Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.