'ipfs object put' is a plumbing command for storing DAG nodes. It reads from stdin, and the output is a base58 encoded multihash. `, LongDescription: ` 'ipfs object put' is a plumbing command for storing DAG nodes. It reads from stdin, and the output is a base58 encoded multihash. Data should be in the format specified by <encoding>. <encoding> may be one of the following: * "protobuf" * "json" `, }, Arguments: []cmds.Argument{ cmds.FileArg("data", true, false, "Data to be stored as a DAG object"), cmds.StringArg("encoding", true, false, "Encoding type of <data>, either \"protobuf\" or \"json\""), }, Run: func(req cmds.Request) (interface{}, error) { n, err := req.Context().GetNode() if err != nil { return nil, err } input, err := req.Files().NextFile() if err != nil && err != io.EOF { return nil, err } encoding := req.Arguments()[0]
return bytes.NewReader(b.Data), nil }, } var blockPutCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Stores input as an IPFS block", ShortDescription: ` ipfs block put is a plumbing command for storing raw ipfs blocks. It reads from stdin, and <key> is a base58 encoded multihash. `, }, Arguments: []cmds.Argument{ cmds.FileArg("data", true, false, "The data to be stored as an IPFS block").EnableStdin(), }, Run: func(req cmds.Request) (interface{}, error) { n, err := req.Context().GetNode() if err != nil { return nil, err } file, err := req.Files().NextFile() if err != nil { return nil, err } data, err := ioutil.ReadAll(file) if err != nil { return nil, err
Names []string } var AddCmd = &cmds.Command{ Helptext: cmds.HelpText{ Tagline: "Add an object to ipfs.", ShortDescription: ` Adds contents of <path> to ipfs. Use -r to add directories. Note that directories are added recursively, to form the ipfs MerkleDAG. A smarter partial add with a staging area (like git) remains to be implemented. `, }, Arguments: []cmds.Argument{ cmds.FileArg("path", true, true, "The path to a file to be added to IPFS").EnableRecursive(), }, Options: []cmds.Option{ cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive) }, Run: func(req cmds.Request) (interface{}, error) { added := &AddOutput{} n, err := req.Context().GetNode() if err != nil { return nil, err } for { file, err := req.Files().NextFile() if err != nil && err != io.EOF { return nil, err