Add File Using Reed-Solomon

API Endpoint

http://localhost:5001/api/v1/add?chunker=reed-solomon

Usage

async saveToIpfs (files) {
    const source = this.btfs.add(
      [...files],
      {
        progress: (prog) => console.log(`received: ${prog}`),
        chunker : "reed-solomon-1-1-256000"
      }
    )
    try {
      for await (const file of source) {
        this.setState({ added_file_hash: file.path })
      }
    } catch (err) {
      console.error(err)
    }
  }
// Usage

mhash, err := s.Add(bytes.NewBufferString("Hello World"))


// Go Wrapper

func (s *Shell) Add(r io.Reader, options ...AddOpts) (string, error) {
	fr := files.NewReaderFile(r)
	slf := files.NewSliceDirectory([]files.DirEntry{files.FileEntry("", fr)})
	fileReader := files.NewMultiFileReader(slf, true)

	var out object
	rb := s.Request("add")
	for _, option := range options {
		option(rb)
	}
	return out.Hash, rb.Body(fileReader).Exec(context.Background(), &out)
}
curl -X POST -F file=@myfile "http://localhost:5001/api/v1/add?chunker=reed-solomon"

Response

{  
   "Name":"myfile",
   "Hash":"Qme8q2XFoGJoMxTZkM21kxQfohk7MpRv5WNq8Vy57K5u74",
   "Size":"197717"
}