Merge pull request #72 from harshavardhana/pr_out_verify_sync_to_be_a_directory
This commit is contained in:
+9
-1
@@ -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)
|
||||
|
||||
+9
-2
@@ -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 <Directory>")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user