alanshaw / ipfs-only-hash

#️⃣ Just enough code to calculate the IPFS hash for some data
MIT License
135 stars 28 forks source link

Error: Content was invalid #30

Open n1c01a5 opened 1 year ago

n1c01a5 commented 1 year ago

If I put a file as param I got this error: Error: Content was invalid.

The code: await Hash.of(file)

How can we compute the hash of a file ?

VadimSaveljev commented 1 year ago

Had same issue, managed to fix it by sending Uint8Array of my file's buffer

      const arrayBuffer = await fetch(url).then(response => response.arrayBuffer());
      const cid = await Hash.of(new Uint8Array(arrayBuffer));