Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion add.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"path"

"github.com/ipfs/go-ipfs-files"
files "github.com/ipfs/go-ipfs-files"
)

type object struct {
Expand Down Expand Up @@ -45,6 +45,14 @@ func RawLeaves(enabled bool) AddOpts {
}
}

// Hash allows for selecting the multihash type
func Hash(hash string) AddOpts {
return func(rb *RequestBuilder) error {
rb.Option("hash", hash)
return nil
}
}

func (s *Shell) Add(r io.Reader, options ...AddOpts) (string, error) {
fr := files.NewReaderFile(r)
slf := files.NewSliceDirectory([]files.DirEntry{files.FileEntry("", fr)})
Expand Down
2 changes: 1 addition & 1 deletion log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func Test_Logger(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
sh := NewLocalShell()
sh := NewShell(shellUrl)
logger, err := sh.GetLogs(ctx)
if err != nil {
t.Fatal(err)
Expand Down
3 changes: 3 additions & 0 deletions shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func TestAdd(t *testing.T) {
mhash, err := s.Add(bytes.NewBufferString("Hello IPFS Shell tests"))
is.Nil(err)
is.Equal(mhash, "QmUfZ9rAdhV5ioBzXKdUTh2ZNsz9bzbkaLVyQ8uc8pj21F")
mhash, err = s.Add(bytes.NewBufferString("Hello IPFS Shell tests"), Hash("sha3-256"))
is.Nil(err)
is.Equal(mhash, "zb2wwqxjxosf8GKEZCwAWSFZ879XFNca3De5yAoh5b2axAffc")
}

func TestRedirect(t *testing.T) {
Expand Down