Is there a way to specify multicodec when adding a file via "/api/v0/add " API?

After adding some files through this API I notice that the MULTICODEC inside returned CIDs are different. Sometimes it’s dag-pb somtimes it’s raw, and seems when the file size is smaller than the chuner size it will be raw, other wise it is dag-pb. So I am wondering if there is a way we can tell IPFS to always use dag-pb as MULTICODEC? I am using Kubo 0.15.0.

Thanks

Which multicodec is used depends on chunker internals, you shouldn’t care about that because any good unixfs implementation supports both raw and dag-pb.

I don’t understand what is the problem here.

Oh, I just realized if I use CID v0, it will stuck to dag-pb, which is sort of OK to me.

--raw-leaves=false, if you are using CIDv1s, but I also wonder what you are doing that makes you care about this.

1 Like

Thanks, I am just trying to make CIDs a little bit predictable which could help me to save some disk space.

CIDv1 using raw leaves save space compared to CIDv0 because they remove the protobuf wrapper than CIDv0 (even if you only keep the digest).

If you want to save space on CIDs store them as binary cids instead of multibase encoded ones.