Skip to content

Commit

Permalink
implement add without pinning
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Oct 7, 2016
1 parent e77c2bd commit 0ee8672
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ type object struct {

// Add a file to ipfs from the given reader, returns the hash of the added file
func (s *Shell) Add(r io.Reader) (string, error) {
return s.addWithOpts(r, true)
}

// AddNoPin a file to ipfs from the given reader, returns the hash of the added file without pinning the file
func (s *Shell) AddNoPin(r io.Reader) (string, error) {
return s.addWithOpts(r, false)
}

func (s *Shell) addWithOpts(r io.Reader, pin bool) (string, error) {
var rc io.ReadCloser
if rclose, ok := r.(io.ReadCloser); ok {
rc = rclose
Expand All @@ -127,6 +136,9 @@ func (s *Shell) Add(r io.Reader) (string, error) {
req := NewRequest(s.url, "add")
req.Body = fileReader
req.Opts["progress"] = "false"
if !pin {
req.Opts["pin"] = "false"
}

resp, err := req.Send(s.httpcli)
if err != nil {
Expand Down

0 comments on commit 0ee8672

Please sign in to comment.