|
@ -1,13 +1,18 @@ |
|
|
package data |
|
|
package data |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"os" |
|
|
|
|
|
"fmt" |
|
|
|
|
|
"bytes" |
|
|
"bytes" |
|
|
|
|
|
"fmt" |
|
|
"io/ioutil" |
|
|
"io/ioutil" |
|
|
|
|
|
"os" |
|
|
|
|
|
|
|
|
shell "github.com/ipfs/go-ipfs-api" |
|
|
shell "github.com/ipfs/go-ipfs-api" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
type Record struct { |
|
|
|
|
|
Shell *shell.Message |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func Publish(object []byte) string { |
|
|
func Publish(object []byte) string { |
|
|
sh := shell.NewShell("localhost:5001") |
|
|
sh := shell.NewShell("localhost:5001") |
|
|
cid, err := sh.Add(bytes.NewBuffer(object)) |
|
|
cid, err := sh.Add(bytes.NewBuffer(object)) |
|
@ -21,13 +26,12 @@ func Publish(object []byte) string { |
|
|
func Pin(path string) { |
|
|
func Pin(path string) { |
|
|
sh := shell.NewShell("localhost:5001") |
|
|
sh := shell.NewShell("localhost:5001") |
|
|
err := sh.Pin(path) |
|
|
err := sh.Pin(path) |
|
|
if err != nil{ |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
fmt.Fprintf(os.Stderr, "error: %s", err) |
|
|
fmt.Fprintf(os.Stderr, "error: %s", err) |
|
|
os.Exit(1) |
|
|
os.Exit(1) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Retrieve(hash string) []byte { |
|
|
func Retrieve(hash string) []byte { |
|
|
sh := shell.NewShell("localhost:5001") |
|
|
sh := shell.NewShell("localhost:5001") |
|
|
reader, err := sh.Cat(hash) |
|
|
reader, err := sh.Cat(hash) |
|
|