-
Notifications
You must be signed in to change notification settings - Fork 134
Closed
Labels
kind/bugA bug in existing code (including security flaws)A bug in existing code (including security flaws)
Description
Bug
When adding a file (with a browser File object) as follows:
const helia = await createHeliaHTTP()
const fs = unixfs(helia)
// Encode the file with UnixFS
const cid = await fs.addFile({
content: file.stream(),
path: file.name
}, { wrapWithDirectory: true })
The returned CID is a raw CID and neither path
nor wrapWithDirectory
are used to wrap the file in a dag-pb UnixFS directory.
Reproduction
https://codepen.io/2color/pen/NPKXzLw?editors=1010
Relevant code paths in helia and js-ipfs-unixfs
helia/packages/unixfs/src/commands/add.ts
Lines 46 to 53 in 3423750
export async function addFile (file: FileCandidate, blockstore: PutStore, options: Partial<ImporterOptions> = {}): Promise<CID> { | |
const { cid } = await importFile(file, blockstore, { | |
...defaultImporterSettings, | |
...options | |
}) | |
return cid | |
} |
https://github.com/ipfs/js-ipfs-unixfs/blob/bf060cda444221225675663e2a760ef562437963/packages/ipfs-unixfs-importer/src/index.ts#L383-L391
https://github.com/ipfs/js-ipfs-unixfs/blob/bf060cda444221225675663e2a760ef562437963/packages/ipfs-unixfs-importer/src/index.ts#L383-L391
Metadata
Metadata
Assignees
Labels
kind/bugA bug in existing code (including security flaws)A bug in existing code (including security flaws)