client.put API is ambiguous and confusing #533
Labels
kind/enhancement
A net-new feature or improvement to an existing feature
need/go-nogo-decision
stack/api-protocols
I find
client.put
API to be confusing and ambiguous. I suspect it inherits an unfortunate API design from ipfs, but I think we can do better.Problem
wrapWithDirectory
controls behavior of the method but in it is often not obvious what the result of it's behavior is, e.g. docs suggest following:https://github.com/web3-storage/docs/blob/85cae31a077fe4325d5dc5149f918a9a6fda6ec5/docs/reference/client-library.md#L133-L146
But even above example produces directory containing files. How can it not unless you provide just a single file ?
Proposal
I would suggest avoiding ambiguity simply by following nft.storage client API design that intentionally avoids ambiguity here and a control flag:
storeBlob
can stores single file. Note that it's intentionallystoreBlob
notstoreFile
because file name and mime type would be meaningless.storeDirectory
stores a filesystem tree and as name suggests produces directory.Note that this makes
wrapWithDirectory
obsolete, want to wrap just use:Want just file without intermediary directory, easy
The text was updated successfully, but these errors were encountered: