I am able to get traits of project using cURL as below
curl -X POST -u “projectId:projectSecreat” “https://ipfs.infura.io:5001/api/v0/get?arg=QmNuChxuijmcDZ1JQE1NMPhZAtmu1QQgqUpN8TxVtXw4aH/1”
How to get same data via golang library
package main
import (
"context"
"encoding/base64"
"fmt"
"net/http"
"os"
ipfsApi "github.com/ipfs/go-ipfs-http-client" // v0.1.0
path "github.com/ipfs/interface-go-ipfs-core/path"
)
func main() {
projectId := "1ylb...."
projectSecret := "1f9...."
httpClient := &http.Client{}
httpApi, err := ipfsApi.NewURLApiWithClient("https://ipfs.infura.io:5001", httpClient)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
httpApi.Headers.Add("Authorization", "Basic "+basicAuth(projectId, projectSecret))
//content := strings.NewReader("Infura IPFS - Getting started demo.")
mypath := path.New("Qmb5zeyvU7ZpotLDzkUmSeMDA71MExp8eJyNeefGdoeA2x")
files, err := httpApi.Object().Get(context.Background(), mypath)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
for i := 0; i < len(files.Links()); i++ {
fmt.Println(files.Links()[i].Cid)
}
fmt.Println(len(files.Links()))
}
func basicAuth(projectId, projectSecret string) string {
auth := projectId + ":" + projectSecret
return base64.StdEncoding.EncodeToString([]byte(auth))
}
This give me right number of links, how to get data which we receive via cURL from links object ?