diff options
| author | Matthew Huie | 2013-08-07 17:14:51 +0400 |
|---|---|---|
| committer | Matthew Huie | 2013-08-07 17:16:10 +0400 |
| commit | 6be6b6bffad2f0e9dad23ba8d0f698ee413c5e08 (patch) | |
| tree | 6fce7226d3040b44c8e499353b779b2bfcb45301 /cli/cli.go | |
| parent | a2e0f10535a1f6996be15c0539a338b6f57e7f79 (diff) | |
| download | gdrive-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.go | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 |
