diff --git a/pkg/s3/client.go b/pkg/s3/client.go index d38c8c8a..40b4f35d 100644 --- a/pkg/s3/client.go +++ b/pkg/s3/client.go @@ -85,7 +85,15 @@ func (c *Client) transport() http.RoundTripper { func (c *Client) bucketURL(bucket string) string { if !c.S3ForcePathStyle { if IsValidBucket(bucket) && !strings.Contains(bucket, ".") { - return fmt.Sprintf("https://%s.%s/", bucket, strings.TrimPrefix(c.endpoint(), "https://")) + var url_ string + if strings.Contains(c.endpoint(), "amazonaws.com") { + url_ = fmt.Sprintf("https://%s.%s/", bucket, strings.TrimPrefix(c.endpoint(), "https://")) + } else if strings.Contains(c.endpoint(), "localhost") || strings.Contains(bucket, "127.0.0.1") { + url_ = fmt.Sprintf("%s/%s", c.endpoint(), bucket) + } else { + url_ = fmt.Sprintf("http://%s.%s/", bucket, strings.TrimPrefix(c.endpoint(), "http://")) + } + return url_ } } return fmt.Sprintf("%s/%s", c.endpoint(), bucket) diff --git a/s3-fs-sync.go b/s3-fs-sync.go index 8e4e330d..ad1af065 100644 --- a/s3-fs-sync.go +++ b/s3-fs-sync.go @@ -78,14 +78,21 @@ func doFsSync(c *cli.Context) { input := path.Clean(c.Args().Get(0)) isValidBucketName(input) // exit here if invalid + fl, err := os.Stat(input) + if os.IsNotExist(err) { + log.Fatal(err) + } + if !fl.IsDir() { + log.Fatal("Should be a directory") + } // Create bucketname, before uploading files - err := s3c.PutBucket(input) + err = s3c.PutBucket(input) if err != nil { log.Fatal(err) } filepath.Walk(input, printWalk) default: - log.Fatal("Shouldn't be here") + log.Fatal("Requires a directory name ") } }