Skip to content

Inconsistent CID Calculation with Example: Addressing a file by CID with UnixFS #765

@YangHYue

Description

@YangHYue

Description: I encountered an issue while using the example "Addressing a file by CID with UnixFS". The CID of a specific file calculated in JavaScript does not match the result from the Go implementation. Additionally, I encountered an error while attempting to export the file.

Expected Behavior: The CID generated in JavaScript should match the CID generated in Go
Go: bafybeidcrqr5y44vp6tw6haladhxs3wc6kdi3ttvlfg37o7slddmayrvqm.
JS: bafybeifg4jtuuqlhjskm6oqq3usq23opono4ggjxkckzteazucnfu76thq

Actual Behavior: The CID generated in JavaScript is different from the expected CID. Moreover, I encountered the following error when trying to export the file:

Uncaught (in promise) NotUnixFSError: invalid wire type 4 at offset 26

Image

Code

      const file = event.target.files[0]
      const helia = await createHelia()
      const fs = unixfs(helia)
      const blockstore = helia.blockstore
      const cid = await fs.addFile({
        content: file.stream(),
        path: file.name,
      })
      console.log(cid.toString())
      const block = await blockstore.get(cid)
      const node = dagPb.decode(block)
      console.log(node)
      const entry = await exporter(cid, blockstore)
      console.info(entry)

File : Mega

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions