-
Notifications
You must be signed in to change notification settings - Fork 299
A function that returns the IPFS addresses of files without uploading them #509
Comments
should be able to be done with |
Exactly, you can do that with the |
Thanks. But, when I pass opts with the key |
By try and error and some analysis, I think has nothing deal with |
@yxliang01 you can take a look at this for inspiration https://github.com/SafeMarket/ux/blob/master/lib/utils/getUnixMultihash.js I agree, this should be added as a utility function somewhere. Most devs (including myself) don't understand the difference between a multihash and an ipfs multihash http://0kalmi.blogspot.com/2015/12/what-goes-into-ipfs-multihash.html |
Thanks @aakilfernandes . While this is handy, I still think |
So... I think this is a bug instead of a question. Anyone has idea? |
Okay, I think I know why. After dipping into the code, I found that add.js doesn't have options support which contradicts the documentation |
What happens with this? I saw a branch containing a fix to this issue which was deleted today without merging... |
Any news on this? |
It looks like In a little test, passing a hardcoded I'd be happy to work on this. I've got some vacation time next week that will take me away but maybe after that. |
Hello, can you tell me the function to produce only-hash using javascript. |
@aifreak A good starting point is the tests: https://github.com/ipfs/js-ipfs-api/blob/3f3ce8a998b42b15623aaed3ed80606cf5ed91cc/test/files.spec.js#L106-L117 You call |
@vmx Thanks for your valuable suggestion but i want to generate ipfs hash on webpage without uploading so, that i can compare the hash. so, i want javascript or any client side code for web to generate multihash of ipfs. |
@aifreak You can use https://github.com/multiformats/js-multihashing-async to hash the actual data and then https://github.com/multiformats/js-multihash to create a multihash out of it. |
@vmx Actually i have added the data to ipfs using ipfs.add() inside javascript code that gives a ipfs hash. Now, i want to genrate that same hash of the data without running the daemon means outside of ipfs so, for that i need javascrip function or code to generate the ipfs hash through webpage. |
Actually there is a code in node js that gives the same hash but that is in nodejs but i want the code in javascript so that i can use it inside <script> tag. |
@aifreak It seems to be supported in js-ipfs (https://github.com/ipfs/js-ipfs/blob/8e3ea44ce260bdd56dd8691e907f55b0eea86c4c/src/core/components/files.js#L26). So you should be able to do something like:
Please note that I haven't tried that, but I hope you get the general idea. |
The |
If I understand right, there is no direct command in |
@jikkujose you can use the |
@jikkujose
The command will return ipfs hash without uploading it. |
@daviddias somehow I am getting the error: @princesinha19 thanks it worked, but I think its still adding it to the repository? |
@jikkujose No it doesn't add it tpo repository. I checked that. |
@princesinha19 cool then! But wish there was a better named command for it than calling it add itself. I know Also, how did you verify it wasn't added to the repo? |
@jikkujose After that, I removed |
Aah! I assumed there was a command line way to list the added files :) |
Kindly, please could you move further conversation on this to https://discuss.ipfs.io/ - thank you |
This would be useful for many applications, especially for experiments.
The text was updated successfully, but these errors were encountered: