You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-3Lines changed: 27 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ A readonly implementation of fsspec for IPFS.
5
5
## Installation
6
6
7
7
You can install `ipfsspec` directly from git with the following command:
8
+
8
9
```bash
9
10
pip install ipfsspec
10
11
```
@@ -22,8 +23,31 @@ with fsspec.open("ipfs://QmZ4tDuvesekSs4qM5ZBKpXiZGun7S2CYtEZRB3DYXkjGx", "r") a
22
23
23
24
The current implementation uses a HTTP gateway to access the data. It uses [IPIP-280](https://github.com/ipfs/specs/pull/280) to determine which gateway to use. If you have a current installation of an IPFS node (e.g. kubo, IPFS Desktop etc...), you should be fine. In case you want to use a different gateway, you can use any of the methods specified in IPIP-280, e.g.:
24
25
25
-
* create the file `~/.ipfs/gateway` with the gateway address as first line
26
-
* define the environment variable `IPFS_GATEWAY` to the gateway address
27
-
* create the file `/etc/ipfs/gateway` with the gateway address as first line
26
+
- create the file `~/.ipfs/gateway` with the gateway address as first line
27
+
- define the environment variable `IPFS_GATEWAY` to the gateway address
28
+
- create the file `/etc/ipfs/gateway` with the gateway address as first line
28
29
29
30
No matter which option you use, the gateway has to be specified as an HTTP(S) url, e.g.: `http://127.0.0.1:8080`.
31
+
32
+
## Implementation details
33
+
34
+
ipfsspec supports retrieval and verification of [UnixFS](https://specs.ipfs.tech/unixfs/) encoded files and directories. UnixFS HAMTs have not been implemented yet.
35
+
36
+
fsspec uses entry points to discover filesystem implementations. When you install ipfsspec, it registers itself via an entry point in its [pyproject.toml](./pyproject.toml):
37
+
38
+
```toml
39
+
[project.entry-points."fsspec.specs"]
40
+
ipfs = "ipfsspec.AsyncIPFSFileSystem"
41
+
```
42
+
43
+
When you call `fsspec.open("ipfs://...")`:
44
+
45
+
1. fsspec scans entry points in the `fsspec.specs` group using Python's package metadata
46
+
2. Finds the ipfs entry point that points to `ipfsspec.AsyncIPFSFileSystem`
47
+
3. Dynamically loads and instantiates that class to handle the request
48
+
49
+
ipfsspec just needs to be installed and have the right entry point declared, and fsspec automatically discovers it.
50
+
51
+
The actual filesystem class (`AsyncIPFSFileSystem`) in [async_ipfs.py](./ipfsspec/async_ipfs.py) inherits from `fsspec.asyn.AsyncFileSystem` and implements the required methods like `_cat_file()`, `_ls()`, etc. to fetch and verify data from [IPFS HTTP trustless gateways](https://specs.ipfs.tech/http-gateways/trustless-gateway/).
52
+
53
+
All data fetched is verified to match the CID by fetching [CAR files](https://ipld.io/specs/transport/car/carv1/) which contain the merkle proofs. This means you don't need to trust the gateway.
0 commit comments