February 2019
Intermediate to advanced
450 pages
9h 59m
English
The IPFS has a feature called Mutable File System (MFS). The MFS is different from your OS file system. Let's create a script to explore this feature and name the script exploring_mfs.py:
import ipfsapiimport ioc = ipfsapi.connect()print("By default our MFS is empty.")print(c.files_ls('/')) # root is / just like Unix filesystemprint("We can create a directory in our MFS.")c.files_mkdir('/classical_movies')print("We can create a file in our MFS.")c.files_write('/classical_movies/titanic', io.BytesIO(b"The ship crashed. The end."), create=True)print("We can copy a file in our MFS.")c.files_cp('/classical_movies/titanic', '/classical_movies/copy_of_titanic')print("We can read the file.")print(c.files_read('/classical_movies/titanic')) ...