From dfbac8d30dfd5ad21299cce6d8561f53685acc08 Mon Sep 17 00:00:00 2001 From: Petter Rasmussen Date: Sat, 21 Mar 2015 11:45:14 +0100 Subject: Add flag to override the transfer chunk size Increasing the chunk size might give you faster upload speeds if you are on a fast connection, see #49. --- drive.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drive.go b/drive.go index 2220200..499d5f6 100644 --- a/drive.go +++ b/drive.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "github.com/prasmussen/google-api-go-client/googleapi" "github.com/prasmussen/gdrive/cli" "github.com/prasmussen/gdrive/gdrive" "github.com/prasmussen/gdrive/util" @@ -47,6 +48,7 @@ type Options struct { Share bool `goptions:"--share, description='Share uploaded file'"` MimeType string `goptions:"--mimetype, description='The MIME type (default will try to figure it out)'"` Convert bool `goptions:"--convert, description='File will be converted to Google Docs format'"` + ChunkSize int64 `goptions:"-C, --chunksize, description='Set chunk size in bytes. Minimum is 262144, default is 1048576. Recommended to be a power of two.'"` } `goptions:"upload"` Download struct { @@ -104,6 +106,12 @@ func main() { case "upload": args := opts.Upload + + // Set custom chunksize if given + if args.ChunkSize >= (1 << 18) { + googleapi.SetChunkSize(args.ChunkSize) + } + if args.Stdin { err = cli.UploadStdin(drive, os.Stdin, args.Title, args.ParentId, args.Share, args.MimeType, args.Convert) } else { -- cgit v1.2.3