minio/cmd/erasure-demo/get.go
Harshavardhana f6a5b61b00 Make get/put more robust
- init folder if not present already in 'get()' call
  - put.go was referencing wrong args - fix it
  - if no OBJECTNAME is specified during 'get' - grab a
    list of files under "~/.minio"
  - Provide new API GetList() for ObjectStorage struct
2014-12-09 03:32:31 -08:00

39 lines
593 B
Go

package main
import (
"io"
"log"
"os"
"github.com/codegangsta/cli"
)
func get(c *cli.Context) {
config, err := parseInput(c)
if err != nil {
log.Fatal(err)
}
var objectReader io.Reader
objectName := c.Args().Get(0)
switch config.storageDriver {
case "fs":
{
if len(objectName) == 0 {
if objectReader, err = fsGetList(config); err != nil {
log.Fatal(err)
}
} else {
if objectReader, err = fsGet(config, objectName); err != nil {
log.Fatal(err)
}
}
}
default:
{
log.Fatal("Unknown driver")
}
}
io.Copy(os.Stdout, objectReader)
}