Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda