Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

How to calculate CID of file data? #84

Closed
bonedaddy opened this issue May 18, 2018 · 2 comments
Closed

How to calculate CID of file data? #84

bonedaddy opened this issue May 18, 2018 · 2 comments
Labels
kind/support A question or request for support

Comments

@bonedaddy
Copy link
Contributor

I'm currently trying to figure out how I can calculate the content hash of a file, without adding it to IPFS. I took a look at the code for the Shell.Add function, however it forwards the request onto ipfs itself, waiting for the returned response to retrieve the hash. What I'm attempting to do is calculate the hash of a file to be able to send that to a user, followed by uploading the hash to my ipfs node. The reason I want to caluclate the hash before uploading it to IPFS, is that this will be quicker to send them a response, instead of say having to wait for an entire 10GB file to be pinned to IPFS.

@magik6k magik6k added the kind/support A question or request for support label May 19, 2018
@magik6k
Copy link
Member

magik6k commented May 19, 2018

ipfs add has --only-hash (or -n) option which calculates the hash. Currently there isn't a function exposing the option here, but it will be done as a part of #76.

There has been some discussion on this topic in https://discuss.ipfs.io/t/how-to-calculate-file-directory-hash/777

@magik6k magik6k closed this as completed May 19, 2018
@bonedaddy
Copy link
Contributor Author

Amazing. Thank you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support
Projects
None yet
Development

No branches or pull requests

2 participants