Created
August 23, 2018 12:49
-
-
Save tobowers/4e505a8e0df4d8d8670aee925cfd1397 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"context" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"github.com/ipsn/go-ipfs/core" | |
"github.com/ipsn/go-ipfs/core/coreunix" | |
) | |
func main() { | |
node, err := core.NewNode(context.TODO(), &core.BuildCfg{Online: true}) | |
if err != nil { | |
log.Fatalf("Failed to start IPFS node: %v", err) | |
} | |
dataa := ioutil.NopCloser(bytes.NewBufferString("testfileA")) | |
str, err := coreunix.Add(node, dataa) | |
if err != nil { | |
panic(err) | |
} | |
fmt.Printf("str: %s\n", str) | |
reader, err := coreunix.Cat(context.TODO(), node, str) | |
if err != nil { | |
log.Fatalf("Failed: %v", err) | |
} | |
blob, err := ioutil.ReadAll(reader) | |
if err != nil { | |
log.Fatalf("Failed to retrieve: %v", err) | |
} | |
fmt.Println(string(blob)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment