Open
Description
Code snipped replicating the issue:
import IPFS from 'ipfs-core'
const ipfs = await IPFS.create()
const { cid } = await ipfs.add(new Uint8Array([1, 2, 3]), {
cidVersion: 1,
wrapWithDirectory: true
})
console.info(cid) // CID(bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354)
The expectation would be to either throw an error or wrap with a directory. From my debugging, it looks that the underlying reason for this is that a path is not provided and unixfs-importer will not be able to properly wrap with a directory. We can make this work with:
import IPFS from 'ipfs-core'
const ipfs = await IPFS.create()
const { cid } = await ipfs.add({ content: new Uint8Array([1, 2, 3]), path: '/path/to/file' }, {
cidVersion: 1,
wrapWithDirectory: true
})
console.info(cid)
We should either just thrown an error in such cases, or have a path inferred. @achingbrain what do you think to be the expectation here?
Related to storacha/ipfs-car#88