Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to retrieve CID from ipfs.io gateway after adding to Helia #226

Closed
geoffoliver opened this issue Aug 8, 2023 · 2 comments
Closed

Comments

@geoffoliver
Copy link

geoffoliver commented Aug 8, 2023

Node version: 18.15.0
OS: MacOS 14
Arch: M2

I'm testing Helia and I'm not able to get things I put into it out onto the IPFS.

I tried following the 301-networking.js example (which, FWIW, is fairly different than the example in the readme), but with no success. The code below will output two messages, Add image.jpg. with CID... and Added string with CID..., but if I plug those CIDs into ipfs.io (for example, this should be a string that says "Hey, suckas!"), the browser tries for a while and eventually times out.

From what I can tell by looking at the createHelia function, it doesn't look like I should need to provide a libp2p property to it, and it'll make one by itself with basically all the same stuff from the 301-networking.js example. Because of that, I'm not providing the libp2p property to the createHelia function like the examples suggest. I did try doing it that way, and still couldn't get the data to show up on the IPFS. Anyway, here's the code:

import fs from 'fs';
import { unixfs } from '@helia/unixfs';
import { strings } from '@helia/strings';
import { FsBlockstore } from 'blockstore-fs';
import { createHelia } from 'helia';
import { MemoryDatastore } from 'datastore-core';

const blockstore = new FsBlockstore('./blockstore');

const datastore = new MemoryDatastore();

const helia = await createHelia({
  blockstore,
  datastore,
});

const ufs = unixfs(helia);

const str = strings(helia);

const cid1 = await ufs.addBytes(Uint8Array.from(fs.readFileSync('./image.jpg')));

console.log(`Added image.jpg with CID ${cid1} to the blockstore`);

const cid2 = await str.add('Hey, suckas!');

console.log(`Added string with CID ${cid2} to the blockstore`);

Saving that as helia..mjs and running it with node helia.mjs will spit out two console logs, but the CIDs that come back won't be accessible from the IPFS.

Because of my network configuration - I'm just using my laptop on my home internet connection - I've also tried manually configuring NAT/port forwarding stuff using the instructions from here, and still couldn't get anything working. Though with how all these libraries are changing, I wonder how valid those instructions are at this point.

All that being said, and for whatever it's worth, if I use the command line ipfs tool, I can add stuff to IPFS and it works great. Same computer, same internet connection, everything.

I appreciate any help and look forward to someone pointing out the incredibly simple and dumb thing I missed :-)

@SgtPooki
Copy link
Member

SgtPooki commented Aug 10, 2023

@geoffoliver Thanks so much for your interest and in-depth explanation.

You should follow #182 for tracking the retrieval of Helia authored content from an IPFS gateway. Unfortunately, we're currently blocked on what you're trying to do.

As an aside, you should remember that content created on a node that turns off (you run a script, log CIDs, and then the script stops executing and no process is running) then your content is no longer available.

For unique content only a single node has, when that node goes away, no one in the IPFS ecosystem can download that content (regardless of blockers currently being tracked by #182). Relevant post in discuss.ipfs.tech regarding this: https://discuss.ipfs.tech/t/how-to-retrieve-content-uploaded-via-helia-using-the-ipfs-gateway/16582/4?u=sgtpooki

I'm closing this as a duplicate of #182.

@SgtPooki SgtPooki changed the title Unable to retrieve CID from IPFS after adding to Helia Unable to retrieve CID from ipfs.io gateway after adding to Helia Aug 10, 2023
@geoffoliver
Copy link
Author

Thanks for getting back to me :-) For what it's worth, my node would keep running after it console.logged out the CIDs, but thank you for the information. I'm looking forward to seeing all the cool stuff that happens with Helia!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

2 participants