ipfs daemon must already be running, but not necessarily as the same user who will mount.
The command line programs follow the pattern from man mount and can be customized with options from man mount.fuse.
/ipfs
This read-only file system represents raw blocks and files in ipfs.
It aims for feature parity with ipfs mount of go-ipfs, but faster.
mkdir /ipfs
mount.ipfs /ipfs
# test
file /ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme
/mfs
This mutable file system represents ipfs files.
Files and directories there are pinned to the local node.
yarn global add git+https://github.com/piedar/js-ipfs-mount.git
# or
# npm install -g git+https://github.com/piedar/js-ipfs-mount.git
This software is beta-quality.
It exposes wide-network content to programs which were never designed for that.
Therefore, always run it inside an unprivileged user account, and never as root.
Be careful opening untrusted links under /ipfs/. Remember, you're still on the internet.
Caveats
Because writes to /mfs are hashed and stored directly into ipfs files write, importing the same file with different tools might create new ipfs blocks!
git clone https://github.com/piedar/js-ipfs-mount
cd js-ipfs-mount
yarn && yarn prepare
DEBUG=* node dist/bin/mount.ipfs.js /ipfs
# hit Ctrl-C to stop
# programs under ./bin/ are marked executable# on *nix systems, you can run them directly without recompiling!
yarn global add ts-node
DEBUG=* TS_NODE_FILES=true bin/mount.ipfs.ts /ipfs
The built-in ipfs mount is really slow, which is the first reason this project exists.
$ ipfs mount
$ time curl --output /dev/null file:///ipfs/${test_file}
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.1M 100 21.1M 0 0 1454k 0 0:00:14 0:00:14 --:--:-- 1609k
real 0m14.887s
user 0m0.008s
sys 0m0.123s
But querying through the local gateway is lightning fast.
$ time curl --output /dev/null http://localhost:8080/ipfs/${test_file}
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.1M 100 21.1M 0 0 351M 0 --:--:-- --:--:-- --:--:-- 351M
real 0m0.066s
user 0m0.004s
sys 0m0.015s
Benchmark js-ipfs-mount fbe7ac6a7c35
Our mount is slower than the http gateway but still faster than ipfs mount.
$ mount.ipfs /ipfs
$ time curl --output /dev/null file:///ipfs/${test_file}
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.1M 100 21.1M 0 0 22.9M 0 --:--:-- --:--:-- --:--:-- 23.7M
real 0m0.949s
user 0m0.009s
sys 0m0.014s
Subsequent access should be way faster because auto_cache works well with immutable IPFS objects.
请发表评论