how can i calculate cid locally .
like below
i only find js repo. is there any java implement?
how can i calculate cid locally .
like below
i only find js repo. is there any java implement?
is there anyone help?
what about this GitHub - ipfs-shipyard/java-ipfs-http-client: A Java implementation of the HTTP IPFS API ?
You get all ipfs commands over the http
i need calculate my file CID hash locally. rather than through http api.
so i neednāt upload to ipfs node to save internet traffic
oh in that case why donāt you see the implementations of the CID itself GitHub - multiformats/cid: Self-describing content-addressed identifiers for distributed systems you can use it without the ipfs.
You need this:
i believe he needs the Java version and he listed that repo already.
Iām failing to understand is this about calculating the CID or using the offline capability of the ipfs. if itās just about the CID you can create it from any buffer.
any example code for calculate CID from buffer.
iām not familiar with java
you need to use multihash then pass that into the CID constructor. Check this >> GitHub - multiformats/js-cid: CID implementation in JavaScript
I worked a bit on this StackOverflow answer, and created the minimal standalone implementation in Go that recreates the CID v1 for the specified file. I am not so familiar with Go, so it is just a minimal viable example.
Hello, this is wrong. It works by chance on small files with raw-cid encoding but nothing else. iirc from my quick look, it chunks and then writes all the chunks to a buffer and hashes that, so chunking happens for nothing. Chunks are not used to build a dag or anything.
The reference implementation of adding is: kubo/core/coreunix/add.go at master Ā· ipfs/kubo Ā· GitHub
There are multiple gotchas around folders etc but for single files they would still need a DAG-builder, like done here: kubo/core/coreunix/add.go at master Ā· ipfs/kubo Ā· GitHub
Thanks @hector, really, it does not build DAG as it should be done. I made this example just to see that for smaller linear data areays it would work. Anyhow, it should be very good to have a tool to chunk the data and visualize CID, and possibly, next the resulting DAG. I guess, all the people who cares about persistence, would want this. As I said, I am not so familiar with Go, so for now I only could do a request through the issue on the repository.
@Jorropo this is confusing not to have a link to Github for this tool on the page. Is there a repository?
I would still like to have it standalone and offline, so could you point me to any related code?
I donāt know where the source for dag.ipfs.tech lives.
boxo and helia have examples on how to add files.
To get the CID you create the unixfs dag but write the blocks to /dev/null
(*in practice you donāt write them anywhere).
Here is the implementation of that feature inside kubo ipfs add --only-hash
:
The code is exactly the same as ipfs add
but it inject mock / null storage which donāt store anything anywhere.
Here is where the boxo example add the file:
nd.Cid()
is the info you want, then you can use an implementation of the storage which doesnāt store anything.
@hector could you point us? Still cannot find it
@hector @Jorropo I have updated my repository involving Boxo in a proper(?) way. I will be very appreciated if you have a quick look at it. The code is very simple, and it allows us to recreate CIDv1 with default DAG builder settings. Would be glad to hear about the underwater stones I did not see.
Probably here GitHub - ipfs-shipyard/ipfs-dag-builder-vis: See how the DAGs get built
@hector @Jorropo I have updated my repository involving Boxo in a proper(?) way. I will be very appreciated if you have a quick look at it. The code is very simple, and it allows us to recreate CIDv1 with default DAG builder settings. Would be glad to hear about the underwater stones I did not see.
GitHub - twdragon/ipfs-cid-local: An example program in Go to calculate IPFS CIDs
It looks OK to me, it should produce the same CIDs as Kubo, this is easily testable with a few big and small files.
It looks OK to me, it should produce the same CIDs as Kubo, this is easily testable with a few big and small files.
It does, cause I tried to keep all the defaults. Thank you for having a look!