aboutsummaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
authorfeschroe2014-04-06 12:14:09 +0200
committerfeschroe2014-04-06 12:14:09 +0200
commitf666e816c8adeadfebd5ea5f044cb4796202bcc3 (patch)
treed7997e9ae20add8502dbe6abb0b1c49a20d00ec6 /cli
parentbd8f53151c39bd024a902b01f623d9daa994a63c (diff)
downloadgdrive-f666e816c8adeadfebd5ea5f044cb4796202bcc3.tar.bz2
Added convert parameter
Convert file to Google Docs format on-the-fly while uploading
Diffstat (limited to 'cli')
-rw-r--r--cli/cli.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/cli/cli.go b/cli/cli.go
index 75ec4e7..4e347fb 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -158,7 +158,8 @@ func Folder(d *gdrive.Drive, title string, parentId string, share bool) error {
}
// Upload file to drive
-func Upload(d *gdrive.Drive, input io.ReadCloser, title string, parentId string, share bool, mimeType string) error {
+func Upload(d *gdrive.Drive, input io.ReadCloser, title string, parentId string, share bool, mimeType string, convert bool) error {
+
// Use filename or 'untitled' as title if no title is specified
if title == "" {
if f, ok := input.(*os.File); ok && input != os.Stdin {
@@ -181,7 +182,11 @@ func Upload(d *gdrive.Drive, input io.ReadCloser, title string, parentId string,
}
getRate := util.MeasureTransferRate()
- info, err := d.Files.Insert(f).Media(input).Do()
+ if convert {
+ fmt.Printf("Converting to Google Docs format enabled\n")
+ }
+
+ info, err := d.Files.Insert(f).Convert(convert).Media(input).Do()
if err != nil {
return fmt.Errorf("An error occurred uploading the document: %v\n", err)
}