2014-12-08 22:40:48 -05:00
|
|
|
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
|
2014-12-09 06:32:31 -05:00
|
|
|
objectName := c.Args().Get(0)
|
|
|
|
|
2014-12-08 22:40:48 -05:00
|
|
|
switch config.storageDriver {
|
|
|
|
case "fs":
|
|
|
|
{
|
2014-12-09 06:32:31 -05:00
|
|
|
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)
|
|
|
|
}
|
2014-12-08 22:40:48 -05:00
|
|
|
}
|
|
|
|
}
|
2014-12-11 03:32:32 -05:00
|
|
|
case "erasure":
|
|
|
|
{
|
2014-12-11 18:35:25 -05:00
|
|
|
if len(objectName) == 0 {
|
|
|
|
if objectReader, err = erasureGetList(config); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if objectReader, err = erasureGet(config, objectName); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2014-12-11 03:32:32 -05:00
|
|
|
}
|
|
|
|
}
|
2014-12-08 22:40:48 -05:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
log.Fatal("Unknown driver")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
io.Copy(os.Stdout, objectReader)
|
|
|
|
}
|