ipfs-inactive / js-ipfs-http-client

[ARCHIVED] now part of the https://github.com/ipfs/js-ipfs repo
Other
1.05k stars 298 forks source link

Unable to add content with the 42.0.0 #1243

Closed xmaysonnave closed 4 years ago

xmaysonnave commented 4 years ago

I tried to qualify the latest with our DApp and was unable to add anything.
I downgraded to the 41.0.1.

Here is the code snippet I use :

    // 1 - https://github.com/ipfs/go-ipfs/issues/5683
    // default chunker: "size-262144"
    // chunker: "rabin-262144-524288-1048576"
    // 2 - TODO: small content generates a wrong cid when cidVersion: 1 is set:
    // Not a 'dag-pb' but a 'raw' multicodec instead
    // We generate a V0 and convert it to a V1
    // https://github.com/xmaysonnave/tiddlywiki-ipfs/issues/14
    const result = await client.add(buffer, {
      cidVersion: 0,
      hashAlg: "sha2-256",
      chunker: "rabin-262144-524288-1048576",
      pin: false
    });
    // Check
    if (result == undefined || result == null || Array.isArray(result) === false || result.length === 0) {
      throw new Error("IPFS client returned an unknown result...");
    }
    // Convert
    const cidv1 = this.cidV0ToCidV1(result[0].hash);
    return {
      hash: cidv1,
      size: result[0].size
    }; 

The first screenshot shows the usual array I receive when added while the second screenshot shows an unfamiliar object, definitely not an array.

ipfs-http-client-add-41 0 1

ipfs-http-client-add-42 0 0

Any advise will be greatly appreciated.

Warmly

xmaysonnave commented 4 years ago

According to the migration guide I receive an Iterable. I close this issue as it's irrelevant. Thanks