vgrichina / nearfs

Distributed file system compatible with IPFS using NEAR blockchain as a backend.
23 stars 3 forks source link
blockchain ipfs nearprotocol web3 web4

NEARFS

NEARFS is a distributed file system compatible with IPFS that uses the NEAR blockchain as a backend. It is a work in progress.

TLDR

Useful tools

How to run gateway

How to run indexer

Environment variables

API

Following IPFS gateway APIs are currently implemented. Note that there might be some differences in details like error handling, etc.

Most notable difference with regular IPFS is that all calls would either return immediately or 404. There is no wait for content to be fetched from other nodes, etc.

Also only CIDv1 is currently supported (see examples).

GET /ipfs/:cid

Returns IPFS file with given CID.

Example:

https://ipfs.web4.near.page/ipfs/bafybeicit72w2sl3agal2jftpkrzwd773fjgdk4dym7pq2pbojyif72v5e

GET /ipfs/:cid/:path

Returns IPFS file with given CID and path.

Example:

https://ipfs.web4.near.page/ipfs/bafybeiepywlzwr2yzyin2bo7k2v5oi37lsgleyvfrf6erjvlze2qec6wkm/privacy.html

Directory listing

If directory is requested and it has no index.html – HTML with its contents is returned.

Otherwise index.html is served.

Example directory:

https://ipfs.web4.near.page/ipfs/bafybeiepywlzwr2yzyin2bo7k2v5oi37lsgleyvfrf6erjvlze2qec6wkm/

Example index.html:

https://ipfs.web4.near.page/ipfs/bafybeidg3ohf4kscsf6cjbgg7vttcvu7q4olena3kwhpl5wl3trhhougyi/dist/

Subdomain Support

NEARFS supports accessing content via subdomains. This allows serving full websites via NEARFS gateway with isolated security context.

How it works

GET http://<cid>.ipfs.web4.near.page/

Returns the content of the root directory for the given CID.

Example:

http://bafybeicit72w2sl3agal2jftpkrzwd773fjgdk4dym7pq2pbojyif72v5e.ipfs.web4.near.page/

GET http://<cid>.ipfs.web4.near.page/:path

Returns the file at the specified path within the directory structure of the given CID.

Example:

http://bafybeiepywlzwr2yzyin2bo7k2v5oi37lsgleyvfrf6erjvlze2qec6wkm.ipfs.web4.near.page/privacy.html

This feature provides a more intuitive way to share and access IPFS content through the NEARFS gateway.