-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support symlinks and other types in ls #27
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,14 @@ | |
|
||
|
||
class IPFSGateway: | ||
""" | ||
Abstrats the IPFS gateway REST API. | ||
|
||
Documentation for the REST API can be found here: [Kubo_RPC_API]_. | ||
|
||
References: | ||
.. [Kubo_RPC_API] http://docs.ipfs.tech.ipns.localhost:8080/reference/kubo/rpc/ | ||
""" | ||
def __init__(self, url): | ||
self.url = url | ||
self.state = "unknown" | ||
|
@@ -166,7 +174,23 @@ def ls(self, path, detail=True, **kwargs): | |
logger.debug("ls on %s", path) | ||
res = self._gw_apipost("ls", arg=path) | ||
links = res["Objects"][0]["Links"] | ||
types = {1: "directory", 2: "file"} | ||
|
||
# Documentation for the type codes doesn't seem to have a great location. | ||
# Currently 2023-10-17, the ls API docs specify the ls return | ||
# structure, but not what the type integers mean: | ||
# http://docs.ipfs.tech/reference/kubo/rpc/#api-v0-ls | ||
# Some information about type codes can be found here: | ||
# https://ipfs-search.readthedocs.io/en/latest/ipfs_datatypes.html | ||
# https://github.com/ipfs/go-unixfs/blob/master/pb/unixfs.proto | ||
|
||
types = { | ||
0: "raw", | ||
1: "directory", | ||
2: "file", | ||
3: "metadata", | ||
4: "symlink", | ||
5: "shard", | ||
} | ||
Comment on lines
+186
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also touch what the generic |
||
if detail: | ||
return [{"name": path + "/" + link["Name"], | ||
"size": link["Size"], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess as long as we are talking read only, we might want to stick to the HTTP Gateway API (not the full RPC API). This should always be available on locally running kubo installations, but should work equally well on public gateways as a fallback.