aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Rasmussen2013-08-07 10:50:38 -0700
committerPetter Rasmussen2013-08-07 10:50:38 -0700
commitaf67666950feb797fe4bfb1b71ffe2a595c42eb2 (patch)
tree6fce7226d3040b44c8e499353b779b2bfcb45301
parenta2e0f10535a1f6996be15c0539a338b6f57e7f79 (diff)
parent6be6b6bffad2f0e9dad23ba8d0f698ee413c5e08 (diff)
downloadgdrive-af67666950feb797fe4bfb1b71ffe2a595c42eb2.tar.bz2
Merge pull request #3 from matthewhuie/master
Added MIME type detection during upload; Google Drive API does not correctly determine MIME type if blank
-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