mirror of
https://github.com/minio/mc.git
synced 2025-11-14 23:42:27 +03:00
Now progress bar is support for Put object
This commit is contained in:
@@ -19,11 +19,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/cheggaaa/pb"
|
||||||
"github.com/minio-io/cli"
|
"github.com/minio-io/cli"
|
||||||
"github.com/minio-io/mc/pkg/client"
|
"github.com/minio-io/mc/pkg/client"
|
||||||
"github.com/minio-io/mc/pkg/client/s3"
|
"github.com/minio-io/mc/pkg/client/s3"
|
||||||
@@ -56,13 +58,24 @@ func (w *walk) putWalk(p string, i os.FileInfo, err error) error {
|
|||||||
info(msg)
|
info(msg)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err = w.s3.Put(bucketname, key, i.Size(), bodyFile)
|
var bar *pb.ProgressBar
|
||||||
|
if !w.args.quiet {
|
||||||
|
// get progress bar
|
||||||
|
bar = startBar(i.Size())
|
||||||
|
}
|
||||||
|
newreader := io.Reader(bodyFile)
|
||||||
|
if !w.args.quiet {
|
||||||
|
bar.Start()
|
||||||
|
newreader = io.TeeReader(bodyFile, bar)
|
||||||
|
}
|
||||||
|
err = w.s3.Put(bucketname, key, i.Size(), newreader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("%s uploaded -- to bucket:%s/%s/%s",
|
if !w.args.quiet {
|
||||||
key, w.args.destination.host, bucketname, key)
|
bar.Finish()
|
||||||
info(msg)
|
info("Success!")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +90,7 @@ func isBucketExist(bucketName string, v []*client.Bucket) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func sourceValidate(input string) error {
|
func sourceValidate(input string) error {
|
||||||
if s3.IsValidBucketName(input) {
|
if !s3.IsValidBucketName(input) {
|
||||||
return fmt.Errorf("Invalid input bucket name [%s]", input)
|
return fmt.Errorf("Invalid input bucket name [%s]", input)
|
||||||
}
|
}
|
||||||
st, err := os.Stat(input)
|
st, err := os.Stat(input)
|
||||||
|
|||||||
19
cmd-cp.go
19
cmd-cp.go
@@ -79,6 +79,11 @@ func firstMode(c *cli.Context, args *cmdArgs) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
var bar *pb.ProgressBar
|
||||||
|
if !args.quiet {
|
||||||
|
// get progress bar
|
||||||
|
bar = startBar(size)
|
||||||
|
}
|
||||||
// http://<bucket>.<hostname> is specified without key
|
// http://<bucket>.<hostname> is specified without key
|
||||||
if args.destination.key == "" {
|
if args.destination.key == "" {
|
||||||
args.destination.key = args.source.key
|
args.destination.key = args.source.key
|
||||||
@@ -87,13 +92,19 @@ func firstMode(c *cli.Context, args *cmdArgs) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = s3c.Put(args.destination.bucket, args.destination.key, size, source)
|
newreader := io.Reader(source)
|
||||||
|
if !args.quiet {
|
||||||
|
bar.Start()
|
||||||
|
newreader = io.TeeReader(source, bar)
|
||||||
|
}
|
||||||
|
err = s3c.Put(args.destination.bucket, args.destination.key, size, newreader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("%s uploaded -- to bucket:(http://%s/%s)", args.source.key,
|
if !args.quiet {
|
||||||
args.destination.bucket, args.destination.key)
|
bar.Finish()
|
||||||
info(msg)
|
info("Success!")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user