Skip to content
This repository has been archived by the owner on Oct 5, 2023. It is now read-only.

No examples of connecting client to a node in README #110

Open
alexanderattar opened this issue Jun 24, 2020 · 5 comments
Open

No examples of connecting client to a node in README #110

alexanderattar opened this issue Jun 24, 2020 · 5 comments
Labels
effort/hours Estimated to take one or several hours exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue status/ready Ready to be worked topic/docs Documentation

Comments

@alexanderattar
Copy link

Hi, there is currently no example of how to connect this client to an ipfs node within the README here or within the godocs. Is it possible this can be added? Something similar to what is provided for go-ipfs-api.

package main

import (
	"fmt"
	"strings"
    	"os"

    	shell "github.com/ipfs/go-ipfs-api"
)

func main() {
	// Where your local node is running on localhost:5001
	sh := shell.NewShell("localhost:5001")
	cid, err := sh.Add(strings.NewReader("hello world!"))
	if err != nil {
        fmt.Fprintf(os.Stderr, "error: %s", err)
        os.Exit(1)
	}
    fmt.Printf("added %s", cid)
}

That would be very helpful for new users to this library. For context, I am doing some testing against remote Infura IPFS nodes to ensure the supported methods function as expected.
Thanks!

@alexanderattar alexanderattar added the need/triage Needs initial labeling and prioritization label Jun 24, 2020
@welcome
Copy link

welcome bot commented Jun 24, 2020

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review.
In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment.
Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

  • "Priority" labels will show how urgent this is for the team.
  • "Status" labels will show if this is ready to be worked on, blocked, or in progress.
  • "Need" labels will indicate if additional input or analysis is required.

Finally, remember to use https://discuss.ipfs.io if you just need general support.

@Stebalien Stebalien added exp/novice Someone with a little familiarity can pick up effort/hours Estimated to take one or several hours help wanted Seeking public contribution on this issue and removed need/triage Needs initial labeling and prioritization labels Jun 29, 2020
@jacobheun jacobheun added status/ready Ready to be worked topic/docs Documentation labels Jul 10, 2020
@jamesthesken
Copy link

Hi @Stebalien , is this repo planning to deprecate https://github.com/ipfs/go-ipfs-api ?

I've been using that in a project but if a switch is going to happen I'd be glad to assist in writing examples here.

Thank you!

@Stebalien
Copy link
Member

Well, the switch is supposed to happen eventually, but nobody's working on making it happen and I don't actually know what's blocking it.

Unfortunately, I'm no longer on this team. Maybe @aschmahmann would know if this is somewhere on the roadmap.

@jamesthesken
Copy link

Hey @aschmahmann, I'd love to contribute to this repo if this client is still on the roadmap. I'd like to contribute some examples if possible, how does this one below look? It is for connecting to the local IPFS node and adding a file:

package main

import (
	"context"
	"fmt"
	"os"
	"strings"

	files "github.com/ipfs/go-ipfs-files"
	ipfshttp "github.com/ipfs/go-ipfs-http-client"
)

func main() {
	// placeholder context
	ctx := context.Background()

	// construct a new HttpApi instance communicating with local IPFS daemon
	// default path: ~/.ipfs
	httpApi, err1 := ipfshttp.NewLocalApi()
	if err1 != nil {
		os.Exit(1)
	}

	// add a file to local IFPS node
	newFile := files.NewReaderFile(strings.NewReader("Hello, IPFS!"))
	cid, err2 := httpApi.Unixfs().Add(ctx, newFile)
	if err2 != nil {
		os.Exit(1)
	}

	fmt.Printf("added %s", cid)
}

@PedrobyJoao
Copy link
Contributor

This example that @jamesthesken gave is great, please someone put it on the Readme!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort/hours Estimated to take one or several hours exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue status/ready Ready to be worked topic/docs Documentation
Projects
None yet
Development

No branches or pull requests

5 participants