diff options
| author | Norman Casagrande | 2014-02-18 12:01:37 +0000 |
|---|---|---|
| committer | Norman Casagrande | 2014-02-18 12:01:37 +0000 |
| commit | f1f81fce96c711c6f6e59d1907966ae2418bea98 (patch) | |
| tree | cf3dc723e8a21ca3a85fb8a35b6fb3aa9bd1470b /cli/cli.go | |
| parent | 0fa147d4fb2e264ceb53521c9d0b21e322753698 (diff) | |
| download | gdrive-f1f81fce96c711c6f6e59d1907966ae2418bea98.tar.bz2 | |
Added support for mime types while uploading
Diffstat (limited to 'cli/cli.go')
| -rw-r--r-- | cli/cli.go | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -158,7 +158,7 @@ func Folder(d *gdrive.Drive, title string, parentId string, share bool) { } // Upload file to drive -func Upload(d *gdrive.Drive, input io.ReadCloser, title string, parentId string, share bool) { +func Upload(d *gdrive.Drive, input io.ReadCloser, title string, parentId string, share bool, mimeType string) { // Use filename or 'untitled' as title if no title is specified if title == "" { if f, ok := input.(*os.File); ok && input != os.Stdin { @@ -168,7 +168,10 @@ func Upload(d *gdrive.Drive, input io.ReadCloser, title string, parentId string, } } - var mimeType = mime.TypeByExtension(filepath.Ext(title)) + if mimeType == "" { + mimeType = mime.TypeByExtension(filepath.Ext(title)) + } + // File instance f := &drive.File{Title: title, MimeType: mimeType} // Set parent (if provided) |
