Skip to content
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

Create ipfs.add flag for specifying base of produced CID #5233

Closed
lidel opened this issue Jul 14, 2018 · 6 comments · Fixed by #5789
Closed

Create ipfs.add flag for specifying base of produced CID #5233

lidel opened this issue Jul 14, 2018 · 6 comments · Fixed by #5789
Assignees
Labels
topic/cidv1b32 Topic cidv1b32

Comments

@lidel
Copy link
Member

lidel commented Jul 14, 2018

This is a small, but important piece on the road to CIDv1 in Base32: https://github.com/ipfs/ipfs/issues/337
IMO it should happen before anything else:

To make migration easier, it should be possible for user to opt-in for different base when adding files:

ipfs add --cid-base=base32 (use of --cid-base should imply --cid-version 1)

Note: it is a separate thing from "specifying full default cidv1 parameters", which is tracked in #5230

cc @kevina @kyledrake @alanshaw (for parity with js-ipfs – ipfs/js-ipfs#1440)

@kevina
Copy link
Contributor

kevina commented Jul 27, 2018

Actually what I plan to implement is a little different. It is a global mbase option. We output CIDs in nearly every command so a global option makes more sense. This option does not imply that newly added files are CIDv1 it simply changes the output (when fully implemented) of all go-ipfs commands to output CIDv1 in the given base.

@kevina
Copy link
Contributor

kevina commented Jul 27, 2018

Note that it doesn't imply CIDv1 because it makes sense to decouple the base used to display CIDv1 and the CID version of newly added files.

@lidel
Copy link
Member Author

lidel commented Jul 27, 2018

@kevina Global flag for default base of outputted CIDs across entire app is a good idea, IIUC it would mitigate issue raised in #5234 👍

Note that it does not remove the need for opt-in --cid-base= parameter in ipfs add, it is a complementary UX feature. Perhaps it should be a separate issue?

Users should have an option to change the default base via ad-hoc command to enable batch scripting that outputs different base depending on added content. I see some scenarios where hashes for some files need to be as short as possible, while others need to conform to some standard or limitation, eg. be URL and Origin-safe. Having --cid-base= parameter in ipfs add will make it easy to handle it programmatically without need for conversion step in userland.

@kevina
Copy link
Contributor

kevina commented Jul 27, 2018

Users should have an option to change the default base via ad-hoc command to enable batch scripting that outputs different base depending on added content.

By a global flag I mean a command line flags that can be used with all ipfs command, not just ipfs add. This is separate from a config option. ipfs add. ipfs add --mbase=base32 --cid-version=1 will be identical to ipfs add --cid-base=base32.

@lidel
Copy link
Member Author

lidel commented Jul 27, 2018

Ack, finally got it, if it is a global commandline param, it brings much more value.
It solves UX around base encoding across all APIs and makes all sorts of scripting easier:

ipfs add --cid-version=1 --mbase=base32 
ipfs resolve /ipns/docs.ipfs.io --mbase=base32
ipfs files ls -l --mbase=base32

👍 from me, as long we implement the same in js-ipfs (cc @alanshaw)

@kevina kevina added status/blocked Unable to be worked further until needs are met and removed status/blocked Unable to be worked further until needs are met labels Aug 13, 2018
@hsanjuan
Copy link
Contributor

(subscribing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment