SlideShare a Scribd company logo
1 of 22
Interplanetary File System
with Python
What we will be talking about
● What is IPFS?
● How is it different from Databases and Torrents?
● Installing in your system and running a peer
● Connecting to IPFS via Python
● Uploading to IPFS using Python
● Fetching from IPFS via Python
● Where to use IPFS?
Pre-requisites
● Knowledge of how internet communication works (Esp. protocols like
HTTP).
● Knowledge of what a database is.
● Knowledge of basic data structures.
● Basics of Python (Functions, Importing libraries).
What is IPFS?
● It is a file storage system of sorts
● Instead of a central database, all the nodes participating are a server for
data storage
● Data is requested using the cryptographic hash of that data instead of IP
address
● This means that if two same files are uploaded, they will have the same
hash, thus no duplication
● Each node/server/peer (same thing!) has an ID, we will call it peerID
How does IPFS store data?
● When you add any content on IPFS network, the data is split into chunks of
256Kb
● These chunks are then distributed to various nodes on network which have
there hash closest to peerId
● Now suppose there are 3 peers with the peer IDs 40a, 10ab. 603c
● So suppose a 768 KB data is stored on the IPFS network
● Now the data is broken into 3 chunks of 256kb and the hash of each chunk
is calculated
How does IPFS store data?
● Now suppose there are 3 peers with the peer IDs 40a, 10ab. 603c
● Suppose the 3 hashes of the files are 42ab, 9bc, 600abc
● These three chunks are then sent to the peer with the ID closest lexically to
the hash of the respective chunk
● Then the address is updated in the Distributed hash table
What is a Distributed Hash Table?
● A distributed hash table is just a hash table which helps in locating the
value of asked key
● While theoretically not the same, it helps to think of a hash table as a
dictionary
● Now assume that this hash-
Table allowed you to query
From multiple devices
So how does one
retrieve data on
IPFS?
● So to fetch data, you request it by
typing: “/ipfs/<hash of data>” on a
node running IPFS
● It will fetch the data and display it in
your web browser using browser’s
protocol (HTTP)
● You can also fetch it using a gateway
(Let’s talk about it later!)
Let’s start coding!
Download and Start IPFS client
● There are two major implementations of IPFS: Go and JavaScript, We will
use Go since it has more peers
● To download IPFS for your system, visit https://docs.ipfs.io/install/
● Now you can use Command Line IPFS or GUI IPFS client, doesn’t matter
since under the hood, they basically run the same thing
● Now start the client
● While you’re on it, Google IPFS companion for your browser, and install it
as a browser extension
Install the Python modules
● We need to install “ipfshttpclient”
● pip install ipfshttpclient
● Otherwise you can build from source:
git clone https://github.com/ipfs/py-ipfs-http-client.git
cd py-ipfs-http-client
flit install --pth-fil
Connecting to the IPFS network from Python
import ipfshttpclient
client = ipfshttpclient.connect('/ip4/127.0.0.1/tcp/5001/http')
Uploading to IPFS using Python
● First, let’s make a file, I will call it “test.txt”
● Then, let’s connect to IPFS like we did last time
● import ipfshttpclient
client = ipfshttpclient.connect('/ip4/127.0.0.1/tcp/5001/http')
res = client.add('test.txt')
● Now we can do print(res) to print the metadata of the uploaded file
Uploading to IPFS using Python
● In test.txt, I had written “Test”
● The output is as follows:
{'Name': 'test.txt',
'Hash':'QmQrXZ4iXdEKQMiQT6GRg2Wy3vxb9exR25sYdaqoHwWWuR',
'Size': '12'}
Let’s check our file!
File metadata
Viewing file content from gateway
IPFS Public Gateways
● You use someone else’s system to access IPFS nodes
● A few good, reliable gateways are:
https://www.eternum.io/
https://ipfs.infura.io/
https://cloudflare-ipfs.com/
https://ipfs.infura.io
Fetching files from IPFS
getfile = client.cat(<CONTENT_ID>)
print(getfile.decode('utf-8'))
IPFS Use - cases
● For distributed storage in Blockchain application
● For non-tampered web services
● Better content delivery networks
And other exciting things!
Thanks!
I am everywhere as Abhinavmir,
thanks for tuning in!

More Related Content

What's hot

Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Etsuji Nakai
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & IntroductionLee Trout
 
Kubernetes Cluster vs Nodes vs Pods vs Containers Comparison
Kubernetes Cluster vs Nodes vs Pods vs Containers ComparisonKubernetes Cluster vs Nodes vs Pods vs Containers Comparison
Kubernetes Cluster vs Nodes vs Pods vs Containers Comparisonjeetendra mandal
 
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...Henning Jacobs
 
Container orchestration overview
Container orchestration overviewContainer orchestration overview
Container orchestration overviewWyn B. Van Devanter
 
IPFS introduction
IPFS introductionIPFS introduction
IPFS introductionGenta M
 
Learning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNILearning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNIHungWei Chiu
 
Data Structures in and on IPFS
Data Structures in and on IPFSData Structures in and on IPFS
Data Structures in and on IPFSC4Media
 
Practical CephFS with nfs today using OpenStack Manila - Ceph Day Berlin - 12...
Practical CephFS with nfs today using OpenStack Manila - Ceph Day Berlin - 12...Practical CephFS with nfs today using OpenStack Manila - Ceph Day Berlin - 12...
Practical CephFS with nfs today using OpenStack Manila - Ceph Day Berlin - 12...TomBarron
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...Simplilearn
 
How we can do Multi-Tenancy on Kubernetes
How we can do Multi-Tenancy on KubernetesHow we can do Multi-Tenancy on Kubernetes
How we can do Multi-Tenancy on KubernetesOpsta
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopSathish VJ
 
[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOSAkihiro Suda
 
Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)
Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)
Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)Brian Brazil
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Herofazalraja
 
A la découverte de kubernetes
A la découverte de kubernetesA la découverte de kubernetes
A la découverte de kubernetesJulien Maitrehenry
 

What's hot (20)

Docker internals
Docker internalsDocker internals
Docker internals
 
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
Architecture Overview: Kubernetes with Red Hat Enterprise Linux 7.1
 
Docker
DockerDocker
Docker
 
Quick introduction to Kubernetes
Quick introduction to KubernetesQuick introduction to Kubernetes
Quick introduction to Kubernetes
 
Terraform: An Overview & Introduction
Terraform: An Overview & IntroductionTerraform: An Overview & Introduction
Terraform: An Overview & Introduction
 
Kubernetes Cluster vs Nodes vs Pods vs Containers Comparison
Kubernetes Cluster vs Nodes vs Pods vs Containers ComparisonKubernetes Cluster vs Nodes vs Pods vs Containers Comparison
Kubernetes Cluster vs Nodes vs Pods vs Containers Comparison
 
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
 
Container orchestration overview
Container orchestration overviewContainer orchestration overview
Container orchestration overview
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
IPFS introduction
IPFS introductionIPFS introduction
IPFS introduction
 
Learning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNILearning how AWS implement AWS VPC CNI
Learning how AWS implement AWS VPC CNI
 
Data Structures in and on IPFS
Data Structures in and on IPFSData Structures in and on IPFS
Data Structures in and on IPFS
 
Practical CephFS with nfs today using OpenStack Manila - Ceph Day Berlin - 12...
Practical CephFS with nfs today using OpenStack Manila - Ceph Day Berlin - 12...Practical CephFS with nfs today using OpenStack Manila - Ceph Day Berlin - 12...
Practical CephFS with nfs today using OpenStack Manila - Ceph Day Berlin - 12...
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
 
How we can do Multi-Tenancy on Kubernetes
How we can do Multi-Tenancy on KubernetesHow we can do Multi-Tenancy on Kubernetes
How we can do Multi-Tenancy on Kubernetes
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
 
[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS
 
Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)
Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)
Monitoring Kubernetes with Prometheus (Kubernetes Ireland, 2016)
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
A la découverte de kubernetes
A la découverte de kubernetesA la découverte de kubernetes
A la découverte de kubernetes
 

Similar to Distributed Storage with IPFS and Python!

Introduction to Filecoin
Introduction to Filecoin   Introduction to Filecoin
Introduction to Filecoin Vanessa Lošić
 
Introduction to IPFS & Filecoin - longer version
Introduction to IPFS & Filecoin - longer versionIntroduction to IPFS & Filecoin - longer version
Introduction to IPFS & Filecoin - longer versionTinaBregovi
 
Interplanetary File System.pptx
Interplanetary File System.pptxInterplanetary File System.pptx
Interplanetary File System.pptxGitam Gadtaula
 
Introduction to IPFS & Filecoin
Introduction to IPFS & FilecoinIntroduction to IPFS & Filecoin
Introduction to IPFS & FilecoinTinaBregovi
 
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...Igalia
 
AIDevWorldApacheNiFi101
AIDevWorldApacheNiFi101AIDevWorldApacheNiFi101
AIDevWorldApacheNiFi101Timothy Spann
 
Decentralized possibilities with filecoin &amp; ipfs_encode filecoin club
Decentralized possibilities with filecoin &amp; ipfs_encode filecoin clubDecentralized possibilities with filecoin &amp; ipfs_encode filecoin club
Decentralized possibilities with filecoin &amp; ipfs_encode filecoin clubKlaraOrban
 
Features & benifits of ipv6 firewall
Features & benifits of ipv6 firewallFeatures & benifits of ipv6 firewall
Features & benifits of ipv6 firewallAnthony Daniel
 
Ipfs installation and demo
Ipfs installation and demoIpfs installation and demo
Ipfs installation and demoNaveen Davis
 
Apache frameworks for Big and Fast Data
Apache frameworks for Big and Fast DataApache frameworks for Big and Fast Data
Apache frameworks for Big and Fast DataNaveen Korakoppa
 
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP ProtocolSerial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP ProtocolSanjay Kumar
 
Structured Streaming with Kafka
Structured Streaming with KafkaStructured Streaming with Kafka
Structured Streaming with Kafkadatamantra
 
PVFS: A Parallel File System for Linux Clusters
PVFS: A Parallel File System for Linux ClustersPVFS: A Parallel File System for Linux Clusters
PVFS: A Parallel File System for Linux ClustersTawose Olamide Timothy
 

Similar to Distributed Storage with IPFS and Python! (20)

Decentralized storage
Decentralized storageDecentralized storage
Decentralized storage
 
Introduction to Filecoin
Introduction to Filecoin   Introduction to Filecoin
Introduction to Filecoin
 
Introduction to IPFS & Filecoin - longer version
Introduction to IPFS & Filecoin - longer versionIntroduction to IPFS & Filecoin - longer version
Introduction to IPFS & Filecoin - longer version
 
Interplanetary File System.pptx
Interplanetary File System.pptxInterplanetary File System.pptx
Interplanetary File System.pptx
 
ipfs-171229085327.pdf
ipfs-171229085327.pdfipfs-171229085327.pdf
ipfs-171229085327.pdf
 
Introduction to IPFS & Filecoin
Introduction to IPFS & FilecoinIntroduction to IPFS & Filecoin
Introduction to IPFS & Filecoin
 
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
Snabb Switch: Riding the HPC wave to simpler, better network appliances (FOSD...
 
AIDevWorldApacheNiFi101
AIDevWorldApacheNiFi101AIDevWorldApacheNiFi101
AIDevWorldApacheNiFi101
 
Decentralized possibilities with filecoin &amp; ipfs_encode filecoin club
Decentralized possibilities with filecoin &amp; ipfs_encode filecoin clubDecentralized possibilities with filecoin &amp; ipfs_encode filecoin club
Decentralized possibilities with filecoin &amp; ipfs_encode filecoin club
 
Features & benifits of ipv6 firewall
Features & benifits of ipv6 firewallFeatures & benifits of ipv6 firewall
Features & benifits of ipv6 firewall
 
IPV6 Under the Hood
IPV6 Under the HoodIPV6 Under the Hood
IPV6 Under the Hood
 
Hadoop Vectored IO
Hadoop Vectored IOHadoop Vectored IO
Hadoop Vectored IO
 
Ipfs installation and demo
Ipfs installation and demoIpfs installation and demo
Ipfs installation and demo
 
Apache frameworks for Big and Fast Data
Apache frameworks for Big and Fast DataApache frameworks for Big and Fast Data
Apache frameworks for Big and Fast Data
 
Kfs presentation
Kfs presentationKfs presentation
Kfs presentation
 
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP ProtocolSerial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
Serial Data from Arduino to Raspberry Pi to MySQL using CoAP Protocol
 
Hades
HadesHades
Hades
 
Structured Streaming with Kafka
Structured Streaming with KafkaStructured Streaming with Kafka
Structured Streaming with Kafka
 
PVFS: A Parallel File System for Linux Clusters
PVFS: A Parallel File System for Linux ClustersPVFS: A Parallel File System for Linux Clusters
PVFS: A Parallel File System for Linux Clusters
 
ACN solved Manual By Ketan.pdf
ACN solved Manual By Ketan.pdfACN solved Manual By Ketan.pdf
ACN solved Manual By Ketan.pdf
 

Recently uploaded

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Recently uploaded (20)

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

Distributed Storage with IPFS and Python!

  • 2.
  • 3. What we will be talking about ● What is IPFS? ● How is it different from Databases and Torrents? ● Installing in your system and running a peer ● Connecting to IPFS via Python ● Uploading to IPFS using Python ● Fetching from IPFS via Python ● Where to use IPFS?
  • 4. Pre-requisites ● Knowledge of how internet communication works (Esp. protocols like HTTP). ● Knowledge of what a database is. ● Knowledge of basic data structures. ● Basics of Python (Functions, Importing libraries).
  • 5. What is IPFS? ● It is a file storage system of sorts ● Instead of a central database, all the nodes participating are a server for data storage ● Data is requested using the cryptographic hash of that data instead of IP address ● This means that if two same files are uploaded, they will have the same hash, thus no duplication ● Each node/server/peer (same thing!) has an ID, we will call it peerID
  • 6. How does IPFS store data? ● When you add any content on IPFS network, the data is split into chunks of 256Kb ● These chunks are then distributed to various nodes on network which have there hash closest to peerId ● Now suppose there are 3 peers with the peer IDs 40a, 10ab. 603c ● So suppose a 768 KB data is stored on the IPFS network ● Now the data is broken into 3 chunks of 256kb and the hash of each chunk is calculated
  • 7. How does IPFS store data? ● Now suppose there are 3 peers with the peer IDs 40a, 10ab. 603c ● Suppose the 3 hashes of the files are 42ab, 9bc, 600abc ● These three chunks are then sent to the peer with the ID closest lexically to the hash of the respective chunk ● Then the address is updated in the Distributed hash table
  • 8. What is a Distributed Hash Table? ● A distributed hash table is just a hash table which helps in locating the value of asked key ● While theoretically not the same, it helps to think of a hash table as a dictionary ● Now assume that this hash- Table allowed you to query From multiple devices
  • 9. So how does one retrieve data on IPFS? ● So to fetch data, you request it by typing: “/ipfs/<hash of data>” on a node running IPFS ● It will fetch the data and display it in your web browser using browser’s protocol (HTTP) ● You can also fetch it using a gateway (Let’s talk about it later!)
  • 11. Download and Start IPFS client ● There are two major implementations of IPFS: Go and JavaScript, We will use Go since it has more peers ● To download IPFS for your system, visit https://docs.ipfs.io/install/ ● Now you can use Command Line IPFS or GUI IPFS client, doesn’t matter since under the hood, they basically run the same thing ● Now start the client ● While you’re on it, Google IPFS companion for your browser, and install it as a browser extension
  • 12. Install the Python modules ● We need to install “ipfshttpclient” ● pip install ipfshttpclient ● Otherwise you can build from source: git clone https://github.com/ipfs/py-ipfs-http-client.git cd py-ipfs-http-client flit install --pth-fil
  • 13. Connecting to the IPFS network from Python import ipfshttpclient client = ipfshttpclient.connect('/ip4/127.0.0.1/tcp/5001/http')
  • 14. Uploading to IPFS using Python ● First, let’s make a file, I will call it “test.txt” ● Then, let’s connect to IPFS like we did last time ● import ipfshttpclient client = ipfshttpclient.connect('/ip4/127.0.0.1/tcp/5001/http') res = client.add('test.txt') ● Now we can do print(res) to print the metadata of the uploaded file
  • 15. Uploading to IPFS using Python ● In test.txt, I had written “Test” ● The output is as follows: {'Name': 'test.txt', 'Hash':'QmQrXZ4iXdEKQMiQT6GRg2Wy3vxb9exR25sYdaqoHwWWuR', 'Size': '12'}
  • 18. Viewing file content from gateway
  • 19. IPFS Public Gateways ● You use someone else’s system to access IPFS nodes ● A few good, reliable gateways are: https://www.eternum.io/ https://ipfs.infura.io/ https://cloudflare-ipfs.com/ https://ipfs.infura.io
  • 20. Fetching files from IPFS getfile = client.cat(<CONTENT_ID>) print(getfile.decode('utf-8'))
  • 21. IPFS Use - cases ● For distributed storage in Blockchain application ● For non-tampered web services ● Better content delivery networks And other exciting things!
  • 22. Thanks! I am everywhere as Abhinavmir, thanks for tuning in!