Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
How to get file contents from ipfs-http-client

I am using ipfs-http-client to read the contents of a file form infura, how do i use the "cat" funtionality to correctly get the data in a string/json format?

 const client = create({
    url: ipfsUrl(),
    headers: {
      authorization: ipfsAuthPhrase(),
    },
  });
  const cidformat = "f" + cid.substring(2);
  const cidV0 = new CID(cidformat).toV0().toString();
  const resp = await client.cat(cidV0);
  let content = [];
  for await (const chunk of resp) {
    content = [...content, ...chunk];
  }
  console.log(content.toString());

right now i am just getting a array of binaries on the console log.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From this point on its just a matter of decoding the content buffer.

If the content is some JSON:

const raw = Buffer.from(content).toString('utf8')
console.log(JSON.parse(raw))

If the content is an image:

Buffer.from(content).toString('base64')
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!