func main() { if len(flags.Args()) < 1 { log.Fatal("remote path must be supplied") } client := manta.DefaultClient() resp, err := client.Put(flags.Arg(0), os.Stdin) if err != nil { log.Fatal(err) } defer resp.Body.Close() if resp.StatusCode != 204 { body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatal(err) } log.Fatalf("%s", body) } }
func main() { if len(flags.Args()) < 1 { log.Fatal("remote path must be supplied") } client, err := manta.DefaultClient() if err != nil { log.Fatal(err) } resp, err := client.Get(flags.Arg(0)) if err != nil { log.Fatal(err) } defer resp.Body.Close() if resp.StatusCode != 200 { body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatal(err) } log.Fatalf("%s", body) } s := struct { Name string `json:"name"` Type string `json:"type"` Mtime string `json:"mtime"` }{} d := json.NewDecoder(resp.Body) for { if err := d.Decode(&s); err != nil { if err == io.EOF { break } log.Fatal(err) } if s.Type == "directory" { fmt.Println(s.Name + "/") } else { fmt.Println(s.Name) } } }