-
Notifications
You must be signed in to change notification settings - Fork 243
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
Question:How I generate Cid before data stored? #64
Comments
ipfs.add is adding the byte[] as a file, which involves wrapping the raw data in a unixfs data structure, so the hash is of different bytes. |
How do I to get the same hash by using java method? |
The short answer is you can't using the add command. Why do you need it in advance? If your data is smaller than 256 KiB you can use the block.put command which doesn't do any wrapping. But you will need to use format "raw". |
Because I need use cid without ipfs service. |
@HanawaBanana |
In general you would need to implement the same chunking algorithm (rabin), encoding (protobufs) and data structures (unixfs) that ipfs uses internally. |
i have created a module which can generate the correct file hash: |
I know the java-ipfs-api just invoke ipfs server.
But now I want to get Cid of byte[] before invoke, I tried java-cid. But the Cid of java-ipfs-api is different from the Cid of java-cid(version 0).
this is my code.
I get different result.
Why? I doubt it maybe the ipfs server not only SHA256 byte[], but also other operation.
If anyone give advices. Thanks a lot!
The text was updated successfully, but these errors were encountered: