aboutsummaryrefslogtreecommitdiffstats
path: root/cli/cli.go
diff options
context:
space:
mode:
authorMatthew Huie2013-08-07 17:14:51 +0400
committerMatthew Huie2013-08-07 17:16:10 +0400
commit6be6b6bffad2f0e9dad23ba8d0f698ee413c5e08 (patch)
tree6fce7226d3040b44c8e499353b779b2bfcb45301 /cli/cli.go
parenta2e0f10535a1f6996be15c0539a338b6f57e7f79 (diff)
downloadgdrive-6be6b6bffad2f0e9dad23ba8d0f698ee413c5e08.tar.bz2
Added MIME type detection during upload; Google Drive API does not correctly determine MIME type if blank
Diffstat (limited to 'cli/cli.go')
-rw-r--r--cli/cli.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/cli/cli.go b/cli/cli.go
index fb25a25..b716b5a 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -6,6 +6,7 @@ import (
"io"
"path/filepath"
"strings"
+ "mime"
"code.google.com/p/google-api-go-client/drive/v2"
"../util"
"../gdrive"
@@ -127,7 +128,11 @@ func Upload(d *gdrive.Drive, input io.ReadCloser, title string, share bool) {
}
}
- metadata := &drive.File{Title: title}
+ var mimeType = mime.TypeByExtension(filepath.Ext(title))
+ metadata := &drive.File{
+ Title: title,
+ MimeType: mimeType,
+ }
getRate := util.MeasureTransferRate()
info, err := d.Files.Insert(metadata).Media(input).Do()
@@ -141,6 +146,7 @@ func Upload(d *gdrive.Drive, input io.ReadCloser, title string, share bool) {
// Print information about uploaded file
printInfo(d, info)
+ fmt.Printf("MIME Type: %s\n", mimeType)
fmt.Printf("Uploaded '%s' at %s, total %s\n", info.Title, getRate(bytes), util.FileSizeFormat(bytes))
// Share file if the share flag was provided