featurebase/util/storage.go
Ben Johnson b06ecf3320 Update import path
This commit updates the import path from:

```
pilosa/*
```

to:

```
github.com/umbel/pilosa/*
```

This follows standard Go convention and makes the project "go gettable".

The README was also updated to reflect the changes.
2015-08-05 22:50:38 -06:00

36 lines
676 B
Go

package util
import (
"io"
"os"
"strings"
"github.com/kr/s3/s3util"
"github.com/umbel/pilosa/config"
)
func setup_storage() {
access_key := config.GetString("AWS_ACCESS_KEY_ID")
secret := config.GetString("AWS_SECRET_ACCESS_KEY")
s3util.DefaultConfig.AccessKey = access_key
s3util.DefaultConfig.SecretKey = secret
}
func Open(s string) (io.ReadCloser, error) {
if isURL(s) {
return s3util.Open(s, nil)
}
return os.Open(s)
}
func Create(s string) (io.WriteCloser, error) {
if isURL(s) {
return s3util.Create(s, nil, nil)
}
return os.Create(s)
}
func isURL(s string) bool {
return strings.HasPrefix(s, "http://") || strings.HasPrefix(s, "https://")
}