In order for IPFS to be successful not just with people who are already committed to a decentralization agenda but in a wider community that might simply want to try something and see if it can do useful work, there is a number of very basic user stories that need to work flawlessly and to be easy to find in the documentation. These basically involve people in common development exploration contexts attempting very simple operations: serve, get, verify, and maybe sync.
I am reasonably proficient with a command line and wish to interact with IPFS using simple command line tools that are sufficiently similar to other commands in that environment.
I have a directory of content (that may have subdirectories) and I want it to be available on IPFS.
The HTTP equivalent is: http-server .
. There are other options that are just as simple, http-server
is widely available (from npm, from brew, runnable with npx if it isn't installed, etc.). When you kill it, it stops serving the content.
In IPFS, that's: XXX
(break it up by serve directory and serve single file)
Someone gave me an ipfs:
or ipns:
URL and I want to download it. I don't know what it is, I just want to get it, save it, poke at it, and do something with it if it's useful.
The HTTP equivalent is curl --ouput file.foo URL
. There are options other than curl
and many ways in which this command can fail, but this will usually work.
In IPFS, that's: XXX
.
We can break this user story into two cases:
The HTTP implementation of these two requires that some other party has published a hash of the resource and made it available in redundant places (i.e. location that presumably won't be compromised if the resource has been compromised). Assuming you obtained a SHA-256 de4db33f
, you can verify a download by running shasum -a 256 downloaded.file
and checking that it matches the hash you have.
If you already have a file and wish to check that it is the same as a remote one, your best bet is also to compare a locally-generated hash to one provided by another part. Otherwise, HTTP lacks a reliable way to verify that a local file is the same as a remote one without downloading it. The Digest
/Want-Digest
pair is deprecated and would require trusting the remote server anyway.
In IPFS, that's: XXX
.
We can think of two applicable substories:
The JSON resource is:
And the update is intended to set the correct answer.
For HTTP (assuming no access control), PUT
ting a file remotely can be invoked with curl --upload-file kitten.jpg https://berjon.com/cats/
.
HTTP also has a PATCH
method, though it is rarely used. It can be paired with JSON Patch like so: curl -X PATCH --data '[{"op": "replace", "path": "/questions/life", "value": 42}]' https://berjon.com/deep-philosophy.json
In IPFS, that's: XXX
.
I am writing a simple Node.js application and wish to interact with IPFS without needing to understand much if anything about it. I want a solution that I can grab off of npm and can paste code for from StackOverflow, I don't want to need to stop working on my app because I need to learn about a whole new thing.
We can break this story up between serving a single resource and serving a directory. In Node, serving up a single resource is:
And serving a directory is:
In IPFS, that's: XXX
.
In Node, fetching a URL (assuming you just want the binary data) is:
In IPFS, that's: XXX
.
In Node, fetching and verifying a URL assumes that you also have the hash already:
In IPFS, that's: XXX
.
In Node, PUT
ting a file is:
And sending a PATCH
is:
Of course, this assumes that the server will expose support for PATCH
, which as usual is unlikely unless it was specifically coded to support it.
In IPFS, that's: XXX
.
I am tinkering with a web page, which I'm testing on localhost
and deploying on https
, and wish to interact with IPFS without needing to understand much if anything about it. I want a solution that I can grab off of npm and can paste code for from StackOverflow, I don't want to need to stop working on my app because I need to learn about a whole new thing.
There isn't really an HTTP way to serve from the browser. One could considering PUT
ting to a remote server, but that's cheating.
In IPFS, that's: XXX
.
For HTTP, this is the same as in Node.
In IPFS, that's: XXX
.
Verifying that a URL matches a provided hash in the browser:
In IPFS, that's: XXX
.
These work the same way they do in Node, except that readFile()
has to be replaced with another way to get at the data (e.g. an uploaded Blob
).
In IPFS, that's: XXX
.
I have a server running some kind of Linux and I want to put an IPFS thing on it. I'm admin, I can install things and change configurations, including opening ports, but I don't want to have to spend the day doing it — whatever I need to do, I need to have a clear and straightforward way to set it up.
This just considers serving because that's the one that's different from accomplishing the same on the a personal device's command line.
For HTTP, that's typically done by running nginx
or Apache
. These are available pre-packaged.
This is where we explain serve, provide, pin
From DN: From my understanding, there’s a subtle difference between the two.
In IPFS, that's: XXX
.