Code Monkey home page Code Monkey logo

go-ipfs-http-client's Introduction

go-ipfs-http-api

⚠️ This package is no longer being maintained here. ⚠️

It has been moved into kubo's repo at github.com/ipfs/kubo/client/rpc.

This allows that any updates or change to kubo's coreapi is immediately reflected on the client too.

License

MIT

go-ipfs-http-client's People

Contributors

aschmahmann avatar bonedaddy avatar dependabot-preview[bot] avatar galargh avatar godcong avatar hinshun avatar hsanjuan avatar ipfs-mgmt-read-write[bot] avatar joeltg avatar jorropo avatar kubuxu avatar lidel avatar magik6k avatar marten-seemann avatar pedrobyjoao avatar petar avatar postables avatar rossjones avatar stebalien avatar stensonb avatar web-flow avatar web3-bot avatar willscott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-ipfs-http-client's Issues

Add a client-side block cache

We can, with little difficulty, throw in a client-side cache over the Dag API. The one drawback is that a GC might be run while we're caching some unpinned object.

v0.6.0 Routing API errors

After upgrading to go-ipfs-http-client v0.6.0 I recieve the following errors when attemping to run my program

# github.com/ipfs/go-ipfs-http-client
../../go/pkg/mod/github.com/ipfs/[email protected]/api.go:214:9: cannot use (*RoutingAPI)(api) (value of type *RoutingAPI) as iface.RoutingAPI value in return statement: *RoutingAPI does not implement iface.RoutingAPI (wrong type for method Put)
                have Put(context.Context, string, []byte) error
                want Put(context.Context, string, []byte, ...options.RoutingPutOption) error
../../go/pkg/mod/github.com/ipfs/[email protected]/dag.go:37:16: undefined: format.DefaultBlockDecoder
../../go/pkg/mod/github.com/ipfs/[email protected]/pin.go:204:16: cannot use &pinVerifyRes{…} (value of type *pinVerifyRes) as iface.PinStatus value in send: *pinVerifyRes does not implement iface.PinStatus (missing method Err)

Part of Dht test failure caused by [email protected]

[email protected] will cause the following test result Fail:

    --- FAIL: TestHttpApi/Dht (20.06s)
        --- PASS: TestHttpApi/Dht/TestDhtFindPeer (11.34s)
        --- FAIL: TestHttpApi/Dht/TestDhtFindProviders (4.46s)
            dht.go:109: got wrong provider:  != QmRGNoLuVF432xDgJY39Mz2L9e43ZNB6EJ6MAvbbPqTysV
        --- FAIL: TestHttpApi/Dht/TestDhtProvide (4.26s)
            dht.go:164: got wrong provider:  != QmY23hJii91v3dqgBPZE1ALWq4FqQU4aQbMPsCNXA6zapp

can .travis.yml be updated to a newer version?
I tested release version 0.6.0 and 0.5.0, the project passed the test

$ go test -test.v  -test.run ^TestHttpApi$
=== RUN   TestHttpApi
=== RUN   TestHttpApi/Block
=== RUN   TestHttpApi/Block/TestBlockPut
=== RUN   TestHttpApi/Block/TestBlockPutFormat
=== RUN   TestHttpApi/Block/TestBlockPutHash
=== RUN   TestHttpApi/Block/TestBlockGet
=== RUN   TestHttpApi/Block/TestBlockRm
=== RUN   TestHttpApi/Block/TestBlockStat
=== RUN   TestHttpApi/Block/TestBlockPin
=== RUN   TestHttpApi/Dag
=== RUN   TestHttpApi/Dag/TestPut
=== RUN   TestHttpApi/Dag/TestPutWithHash
=== RUN   TestHttpApi/Dag/TestPath
=== RUN   TestHttpApi/Dag/TestTree
=== RUN   TestHttpApi/Dag/TestBatch
=== RUN   TestHttpApi/Dht
=== RUN   TestHttpApi/Dht/TestDhtFindPeer
=== RUN   TestHttpApi/Dht/TestDhtFindProviders
=== RUN   TestHttpApi/Dht/TestDhtProvide
=== RUN   TestHttpApi/TestsCancelCtx
--- PASS: TestHttpApi (18.56s)
    --- PASS: TestHttpApi/Block (3.41s)
        --- PASS: TestHttpApi/Block/TestBlockPut (0.08s)
        --- PASS: TestHttpApi/Block/TestBlockPutFormat (0.07s)
        --- PASS: TestHttpApi/Block/TestBlockPutHash (0.10s)
        --- PASS: TestHttpApi/Block/TestBlockGet (0.10s)
        --- PASS: TestHttpApi/Block/TestBlockRm (0.13s)
        --- PASS: TestHttpApi/Block/TestBlockStat (0.07s)
        --- PASS: TestHttpApi/Block/TestBlockPin (0.27s)
    --- PASS: TestHttpApi/Dag (0.60s)
        --- PASS: TestHttpApi/Dag/TestPut (0.11s)
        --- PASS: TestHttpApi/Dag/TestPutWithHash (0.09s)
        --- PASS: TestHttpApi/Dag/TestPath (0.17s)
        --- PASS: TestHttpApi/Dag/TestTree (0.12s)
        --- PASS: TestHttpApi/Dag/TestBatch (0.12s)
    --- PASS: TestHttpApi/Dht (14.54s)
        --- PASS: TestHttpApi/Dht/TestDhtFindPeer (5.21s)
        --- PASS: TestHttpApi/Dht/TestDhtFindProviders (4.64s)
        --- PASS: TestHttpApi/Dht/TestDhtProvide (4.69s)
    --- PASS: TestHttpApi/TestsCancelCtx (0.00s)
PASS
ok      github.com/ipfs/go-ipfs-http-client     18.589s
$ ipfs version
ipfs version 0.5.0

How to invoke 'ipfs files' commands?

I am writing a Go script to add real-time HLS live video segments to a remote IPFS machine, while I am using this client, I cannot find the file operation commands like ipfs files cp, ipfs files rm, ipfs files mkdir and ipfs files ls.
So far I can only use api.Unixfs().Add(), but the the pinned file names show in CIDs which carry no time information, I cannot unpin the files that created before certain time point.
Is there any way to invoke those commands?

Thanks,

No examples of connecting client to a node in README

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!

Using NewApiWithClient uses HTTP even when HTTPS requested

When using NewApiWithClient and providing a multiaddress, it results in a HTTP request, even if the multiaddress specifies HTTPS.

For example,

api, _ := NewApiWithClient(ma.NewMultiaddr("/dns4/example.com/tcp/443/https"), &http.Client{})
api.url == "example.com:80"

# in request.go we find 
if !strings.HasPrefix(url, "http") {
    url = "http://" + url
}

NewApiWithClient should return a HttpApi whose url contains the url protocol (http or https).

Extract request handling code

It's duplicated in go-ipfs-api, if it can be extracted it would make maintaining both libraries at the same time easier

some interface was not exist in this api

I am sorry to be bothered many times.
now i has two questions:

  1. in this package /api/v0/add was not found. will add this interface later?

  2. (api *PinAPI) Ls(ctx context.Context, opts ...caopts.PinLsOption) has no arg parameter to input.
    i see the https://docs.ipfs.io/reference/api/http/#api-v0-pin-ls has it.
    and i neet it now. will add this parameter in this interface ?

Use CoreAPI within `Unixfs().Get()`

Currently, this directly invokes the ls HTTP API endpoint but that means we need to duplicate some logic. It would be nice if we could just call Unixfs().Ls() and use that.

want use this api in different machine

the api file can only used in the same machine.
if you are running in the docker.
you cant visit the api file out of the container.
so we need create the api with a string address as you know.
i add a pull request to added a create function

ps: i found a path join miss in windows. so i fixed it.

pull path:

#23

Using Data ObjectAPI results in invalid Character during parsing of object

I am using infura go-ipfs-http-client to get data for given path. I get data, but when unmarshalling json to Struct it fails with below error

panic: invalid character '\b' looking for beginning of value

Code:

//content := strings.NewReader("Infura IPFS - Getting started demo.")
	mypath := path.New("Qmb5zeyvU7ZpotLDzkUmSeMDA71MExp8eJyNeefGdoeA2x/2")
	reader, err := httpApi.Object().Data(context.Background(), mypath)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	var nftData NFTTraitData
	data, _ := ioutil.ReadAll(reader)

	err1 := json.Unmarshal([]byte(data), &nftData)
	if err1 != nil {
		panic(err1)
	}

Response received in "data" field

☻↕�♣{"name":"Obit #2","description":"AN 8-BIT OBITUARY OF FAMILY FIENDS\n\nThere are 7,132 Obits. We are all unique, restless souls of our own generation. Dead Ringers are the most coveted of the clan but ownership of any Obit will grant you access to exclusive launches, airdrops, and other surprising pleasures. Grave pleasures indeed.\n\nVisit the [Obits website](https://obitsnft.com) for more details.","background_color":"cccccc","image":"ipfs://QmPASmu4tqbgwuceqWtHbEZTrn24zsva1NDBxpfzEjVpQR/2.png","external_url":"https://obitsnft.com","attributes":[{"trait_type":"type","value":"Female"},{"trait_type":"Accessory","value":"Black Side"},{"trait_type":"Accessory","value":"Cigar"},{"trait_type":"Lived","value":"1999 - 2018"}]}↑�♣

Do we need to perform some decoding etc?

ipfs-http-client files/write api POST request : {"Message":"file argument was nil","Code":0,"Type":"error"}

Hello all,

I am struggling to get a "write" working on the mfs via the ipfs-http-api,
however a web-form or a curl curl -F [email protected] "http://localhost:5001/api/v0/files/write?arg=/tmp/myfile&create=true"
works fine.

I am using LWP::UserAgent from a perl script;
here is the code I am running (note the post request works for a "ipfs add").

#!/usr/bin/perl
use LWP::UserAgent;

my $filepath='/tmp/data.txt';
my $filename="/my/files/data.txt";
my $data="hello, World!";
my $url="http://127.0.0.1:5001/api/v0/files/write?arg=$filename&create=1&parents=1";
my $ua = LWP::UserAgent->new();
my $form = [
      'file' => ["$filepath" => "$filename", Content => "$data" ]
#      'file' => ["$filepath" => "$filename" ]
   ];

my $resp = $ua->post($url,$form, 'Content-Type' => 'multipart/form-data;boundary=-----a-special-boundary-543-67');
printf "X-Status: %s\n",$resp->status_line;
if ($resp->is_success) {
my $content = $resp->decoded_content;
# ...
}
printf "X-content: %s\n",$resp->decoded_content;

what is odd it that the LWP::UAgent call work for an ipfs add, but not for an ipfs files write ?
the error message I have is : {"Message":"file argument was nil","Code":0,"Type":"error"}

my complete script is : write_api.pl.txt

please advise,

thank you

Not compatible with `github.com/ipfs/[email protected]`

Description

Projects that depend on ipfs/[email protected] cannot use ipfs/[email protected]. If we try, we get errors like:

go build .
# github.com/libp2p/go-libp2p-core/network
../../../go/pkg/mod/github.com/libp2p/[email protected]/network/rcmgr.go:166:27: network.NullResourceManager (type) is not an expression

go mod why github.com/libp2p/go-libp2p-core/network
# github.com/libp2p/go-libp2p-core/network
github.com/ipfs/go-ipfs-http-client
github.com/libp2p/go-libp2p-core/network

ipfs/go-ipfs-http-client depends on:

github.com/ipfs/interface-go-ipfs-core v0.7.0

Which depends on:

github.com/libp2p/go-libp2p-core v0.8.6

But is archived and contains deprecated methods like:

https://github.com/libp2p/go-libp2p-core/blob/654214c1b3401c0363ef464ce9db7e1b04a7ef3f/network/rcmgr.go#L165-L166

Potential next steps?

  1. Refactor ipfs/interface-go-ipfs-core to depend on github.com/libp2p/[email protected], and use its core package instead of github.com/libp2p/[email protected]
  2. Update ipfs/go-ipfs-http-client to use the new ipfs/interface-go-ipfs-core using github.com/libp2p/[email protected]

Anything else

I wanted to surface an issue to the community to get it's corresponding guidance. Let me know what you think? 🙏

Consider the place of non-core APIs

For example, log/tail. These are useful APIs but we may not want to stabilize them. Thoughts? We do expose Request so we could, alternatively, provide some kind of "unstable" wrapper:

type UnstableAPI struct {
  *HttpApi
}

... unstable stuff

Or we could just document these interfaces as "unstable".

Error while uploading file on IPFS

Hi team,

I have setup a private IPFS cluster based network for decentralized files storage, and I'm using IPFS-Cluster-http client for adding files into the network. I have a setup of 3 cluster nodes and correspondingly 1 IPFS node against each of the Cluster node.

Now while adding multiple files using the /add API I'm getting the output of the stream data with multiple CIDs, but while I'm searching for those CIDs in my cluster node using:

ipfs-cluster-ctl pin ls | grep "[CID]"

I'm not able to fetch the details corresponding to passed CID, but while fetching the file using get API call by passing the given CID
I'm able to retrieve the file.

And, while I'm trying to pin the CID manually by using:

ipfs-cluster-ctl pin add [CID]

then I'm getting this error:

/data/ipfs/datastore/368613.log: no space left on device

Can someone please help me with the issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.