From 01ef731036bfff516ee26baa8e3c1ec25c60ecbb Mon Sep 17 00:00:00 2001 From: Petter Rasmussen Date: Sat, 23 Jan 2016 22:08:01 +0100 Subject: Implement upload via stdin --- gdrive.go | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'gdrive.go') diff --git a/gdrive.go b/gdrive.go index 7c7d39f..03f5e3b 100644 --- a/gdrive.go +++ b/gdrive.go @@ -11,6 +11,7 @@ const Version = "2.0.0" const DefaultMaxFiles = 30 const DefaultNameWidth = 40 +const DefaultUploadChunkSize = 8 * 1024 * 1024 const DefaultQuery = "trashed = false and 'me' in owners" const DefaultShareRole = "reader" const DefaultShareType = "anyone" @@ -181,12 +182,38 @@ func main() { Description: "Hide progress", OmitValue: true, }, + cli.StringFlag{ + Name: "mime", + Patterns: []string{"--mime"}, + Description: "Force mime type", + }, cli.BoolFlag{ - Name: "stdin", - Patterns: []string{"--stdin"}, - Description: "Use stdin as file content", + Name: "share", + Patterns: []string{"--share"}, + Description: "Share file", OmitValue: true, }, + }, + }, + }, + &cli.Handler{ + Pattern: "[global options] upload stdin [options] ", + Description: "Upload file from stdin", + Callback: uploadStdinHandler, + Flags: cli.Flags{ + "global options": globalFlags, + "options": []cli.Flag{ + cli.StringSliceFlag{ + Name: "parent", + Patterns: []string{"-p", "--parent"}, + Description: "Parent id, used to upload file to a specific directory, can be specified multiple times to give many parents", + }, + cli.IntFlag{ + Name: "chunksize", + Patterns: []string{"--chunksize"}, + Description: fmt.Sprintf("Set chunk size in bytes, default: %d", DefaultUploadChunkSize), + DefaultValue: DefaultUploadChunkSize, + }, cli.StringFlag{ Name: "mime", Patterns: []string{"--mime"}, -- cgit v1.2.3