Skip to content

Commit

Permalink
Merge pull request prasmussen#187 from vandenoever/master
Browse files Browse the repository at this point in the history
Add --mime option to gdrive import
  • Loading branch information
prasmussen authored Sep 6, 2016
2 parents 604140a + 5406c61 commit 9efbb88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drive/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ import (

type ImportArgs struct {
Out io.Writer
Mime string
Progress io.Writer
Path string
Parents []string
}

func (self *Drive) Import(args ImportArgs) error {
fromMime := getMimeType(args.Path)
fromMime := args.Mime
if fromMime == "" {
return fmt.Errorf("Could not determine mime type of file")
fromMime = getMimeType(args.Path)
}
if fromMime == "" {
return fmt.Errorf("Could not determine mime type of file, use --mime")
}

about, err := self.service.About.Get().Fields("importFormats").Do()
Expand Down
5 changes: 5 additions & 0 deletions gdrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ func main() {
Description: "Hide progress",
OmitValue: true,
},
cli.StringFlag{
Name: "mime",
Patterns: []string{"--mime"},
Description: "Mime type of imported file",
},
),
},
},
Expand Down
1 change: 1 addition & 0 deletions handlers_drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func infoHandler(ctx cli.Context) {
func importHandler(ctx cli.Context) {
args := ctx.Args()
err := newDrive(args).Import(drive.ImportArgs{
Mime: args.String("mime"),
Out: os.Stdout,
Path: args.String("path"),
Parents: args.StringSlice("parent"),
Expand Down

0 comments on commit 9efbb88

Please sign in to comment.