diff options
| author | Horus3 | 2015-08-01 23:56:26 +0200 |
|---|---|---|
| committer | Horus3 | 2015-08-01 23:56:26 +0200 |
| commit | 6afcbc7ba57d80bacace21b6e73ca474dd8217ca (patch) | |
| tree | 41df2c31d4333a47b8d6c97eb061626e69f08841 | |
| parent | f80efe5616ba247a1fff074b0876631a9bfb6f96 (diff) | |
| download | mandible-6afcbc7ba57d80bacace21b6e73ca474dd8217ca.tar.gz | |
Satisfy imagestore interface
| -rw-r--r-- | cli/imgup/stuff.go | 37 | ||||
| -rw-r--r-- | imagestore/gcsstore.go | 2 | ||||
| -rw-r--r-- | imagestore/s3store.go | 2 |
3 files changed, 2 insertions, 39 deletions
diff --git a/cli/imgup/stuff.go b/cli/imgup/stuff.go deleted file mode 100644 index 13e3c29..0000000 --- a/cli/imgup/stuff.go +++ /dev/null @@ -1,37 +0,0 @@ -package main - -import ( - "fmt" - "github.com/canerdogan/go-autoupdate" - "net/http" - "os" - "strings" -) - -func isUrl(url string) bool { - return strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") -} - -func isImage(filePath string) bool { - file, err := os.Open(filePath) - if err != nil { - fmt.Println("There was an error.") - fmt.Println("Technical details: " + err.Error()) - return false - } - buff := make([]byte, 512) - _, err = file.Read(buff) - return strings.Contains(http.DetectContentType(buff), "image") -} - -func doUpdate(url string) { - fmt.Println("Update binary from "+url, "...") - err, _ := update.FromUrl(url) - if err != nil { - fmt.Print("\n") - fmt.Println("Update failed!") - os.Exit(1) - } - fmt.Println("Update completed!") - fmt.Print("\n") -} diff --git a/imagestore/gcsstore.go b/imagestore/gcsstore.go index 798d4eb..67da3d7 100644 --- a/imagestore/gcsstore.go +++ b/imagestore/gcsstore.go @@ -32,7 +32,7 @@ func (this *GCSImageStore) Exists(obj *StoreObject) (bool, error) { return true, nil } -func (this *GCSImageStore) Save(src string, obj *StoreObject) (*StoreObject, error) { +func (this *GCSImageStore) Save(src string, obj *StoreObject, url string) (*StoreObject, error) { data, err := ioutil.ReadFile(src) if err != nil { log.Printf("error on read file: %s", err) diff --git a/imagestore/s3store.go b/imagestore/s3store.go index e023fcc..c31a45f 100644 --- a/imagestore/s3store.go +++ b/imagestore/s3store.go @@ -31,7 +31,7 @@ func (this *S3ImageStore) Exists(obj *StoreObject) (bool, error) { return (response.StatusCode == 200), nil } -func (this *S3ImageStore) Save(src string, obj *StoreObject) (*StoreObject, error) { +func (this *S3ImageStore) Save(src string, obj *StoreObject, url string) (*StoreObject, error) { bucket := this.client.Bucket(this.bucketName) data, err := ioutil.ReadFile(src) |
