-2

I tried to upload an object into IPFS but there was an error

Input not supported. Expected Buffer|ReadableStream|PullStream|File|Array<Object> got object

this is my javascript code :

     let data = {
        name: bot,
        description: "",
        image: "https://ipfs.infura.io/ipfs/myimagehash",
      };

      const client = ipfsClient({
        host: "ipfs.infura.io",
        port: 5001,
        protocol: "https",
      });

      try {
        const added = await client.add(data);
        const url = `https://ipfs.infura.io/ipfs/${added[0].path}`;
        return url;
      } catch (error) {
        console.log("Error uploading file: ", error);
      }
hora
  • 25
  • 5

1 Answers1

0

ok I solved this problem this way:

let buffer = Buffer.from(JSON.stringify(this.form));
const added = await client.add(buffer);
hora
  • 25
  • 5