ipfs / ipfs/kubo

Get some info about UnixFS objects on public IPFS HTTP API

Open
#8,528 2 comments 0 reactions 0 assignees View on GitHub
kind/enhancement P2 topic/gateway
Dominant language
Go
Stars
17.1k
Forks
3.2k
Avg merge
3d 18h
Merged PRs (30d)
11

Description

### Checklist

- [X] My issue is specific & actionable.
- [X] I am not suggesting a protocol enhancement.
- [X] I have searched on the [issue tracker](https://github.com/ipfs/go-ipfs/issues?q=is%3Aissue) for my issue.

### Description

I am implementing a backend to access IPFS via the Python library [fsspec](https://filesystem-spec.readthedocs.io) at [ipfsspec](https://github.com/d70-t/ipfsspec). To do so (and to save me from implementing the IPFS protocol in Python), the plan is to access UnixFS files and directories on IPFS via a HTTP gateway. An `fsspec` backend needs to implement a function `info(path)` which must return

* if the thing behind a path is a directory or a file
* if it is a file, the size of the file

To me, this seems to be a reasonable requirement for other generic filesystem abstractions as well, thus I assume that this feature request could be of broader interest.

While the [`/v0/files/stat`](https://docs.ipfs.io/reference/http/api/#api-v0-files-stat) provides this kind of information, this endpoint is often not reachable on public gateways.

Another option to obtain this information is to perform a `HEAD` request towards `http://gateway/ipfs/CID`, which in case of a file provides the size in the `content-length` header and which (seemingly) lets me discriminate between file and directory using the `etag` header. This method works on some public gateways, but scares me as well, as this doesn't seem to be the right use of observable API features.

I see three possible ways to obtain the desired functionality:
* It is already implemented and I didn't find it?
* Move / replicate the `files/stat` API to public gateway port (could this be `GET` as well?)
* Implement and document HTTP headers which include this information and are to be returned when `/ipfs/CID` is requested

Tagging @whyrusleeping as I've been talking to him about this already on slack.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.