Skip to content

Instantly share code, notes, and snippets.

@tarekbadrshalaan
Created June 1, 2019 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarekbadrshalaan/3efa2d69d169d00dc5d717e9afa1b284 to your computer and use it in GitHub Desktop.
Save tarekbadrshalaan/3efa2d69d169d00dc5d717e9afa1b284 to your computer and use it in GitHub Desktop.
this Gist about using new ipfs http client (go-ipfs-http-client)
package main
import (
"context"
"fmt"
httpapi "github.com/ipfs/go-ipfs-http-client"
path "github.com/ipfs/interface-go-ipfs-core/path"
)
func main() {
api, err := httpapi.NewLocalApi()
if err != nil {
panic(err)
}
mypath := path.New("QmbhrwAZ9QSVi2BE7o8NzbiEk27ALD21XjVp8DFNTWPZmJ")
dirchen , err := api.Unixfs().Ls(context.Background(),mypath)
if err != nil {
panic(err)
}
for dir := range dirchen{
fmt.Println(dir)
}
files , err := api.Unixfs().Get(context.Background(),mypath)
if err != nil {
panic(err)
}
fmt.Println(files.Size())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment