ipfs / helia

An implementation of IPFS in JavaScript
https://helia.io
Other
916 stars 95 forks source link

How to upload to IPFS with Helia using an Infura node? #453

Closed gabrielstoica closed 7 months ago

gabrielstoica commented 7 months ago

Hi!

I'm currently migrating from ipfs-http-client to Helia. In the past, I've been using Infura node to upload to IPFS, with an approach pretty much similar to this one:

import { create } from "ipfs-http-client";

const PROJECT_ID = "";
const PROJECT_SECRET = "";
const IPFS_ENDPOINT = "https://ipfs.infura.io:5001";

const main = async () => {
  const authorization = "Basic " + Buffer.from(PROJECT_ID + ":" + PROJECT_SECRET).toString("base64");
  const client = create({
    url: IPFS_ENDPOINT,
    headers: { authorization: authorization },
  });

  let data = {
    trait1: "value1",
    trait2: "value2",
  };
  data = JSON.stringify(data, null, 2);
  const { cid } = await client.add(data);
  console.log(`CID: ${cid}`);
};

main();

Is it still possible to migrate this approach to use Helia rather than rely on the ipfs-http-client? Thanks!

gabrielstoica commented 7 months ago

Hi @achingbrain!

Found that a similar issue was raised here: https://github.com/ipfs/helia/issues/157. After some research I understand that js-kubo-rpc-client should be used as a replacement for ipfs-http-client.

Since the Kubo RPC Client is still a work in progress and in active deployment, should ipfs-http-client still be used for now?

2color commented 7 months ago

Hey @gabrielstoica,

https://github.com/ipfs/js-kubo-rpc-client is the correct library which replaces the now deprecated ipfs-http-client.