Description
tldr this is attempt to improve how do we want to represent non-unixfs DAGs on the HTTP gateway under /ipfs/ and /ipns/ paths by doing CAR export when data is not a raw/unixfs
Today: only unixfs+raw
Right now the /ipfs/
path on gateway only supports dag-pb
+raw
, everything else fails with unrecognized object type
error:
Gateway exposes /api/v0/get
so one can read blobs with other DAGs that way, but people rarely use it.
Future: export anything
I believe the HTTP gateways should return every DAG type.
Here is initial idea: we recently added support for CAR import/export to go-ipfs (ipfs/kubo#6870) – what if we return non-unixfs/raw DAGs as .car
.ipfs.dag
files?
- CAR format makes it easy for people to import/export DAGs
- gateway would not need to know how to render specific codec to be useful for data distribution
- gateway could return CAR with proper cache control header, namely the
immutable
hint for everything under/ipfs/
- we would set proper content-disposition header to ensure
{cid}.ipfs.dag
filename and trigger download, so the browser does not try to render the blob - we could support
?download=dag
everywhere, so even unixfs DAG could be fetched as CAR from any gateway- update:
?format=car
is more flexible, as it allows forformat=tar
orjson
for dag-cbor (feat: serve CBOR encoded DAG nodes from the gateway kubo#8037)
- update:
cc @mikeal @aschmahmann @autonome @Gozala @achingbrain – is this a good idea? any concerns? would PR be accepted?
Future: import DAGs
If we have export.. could we also add import? This could be safely enabled on localhost, and people could experiment with this on public gateways (there, it could be guarded by reverse proxy or some bearer token):
- we could improve the concept of a writable gateway to support DAG import via
HTTP PUT /ipfs/{cid}
- IPNS publishing could be as easy as
HTTP PUT /ipns/{libp2p-key}
References
- https://docs.ipfs.io/reference/cli/#ipfs-dag-export / https://docs.ipfs.io/reference/cli/#ipfs-dag-import
- DAG Import/Export : DAG Import/Export kubo#6870
- import/export a DAG from/to a CAR file: feat: import/export a DAG from/to a CAR file js-ipfs#2745
?download=true
support was recently added inhttps://github.com/ipfs/go-ipfs/pull/7677
- DAR format (streamable + optional index for random access) https://github.com/anorth/go-dar
- Example of
Content-Location
in response to specificAccept
in request: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Location#examples