Skip to content

Commit

Permalink
[develop] mkdir support absolute path for parents
Browse files Browse the repository at this point in the history
  • Loading branch information
SGH623QVQT committed Nov 6, 2017
1 parent bb49c69 commit dcfa3b9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion drive/mkdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package drive

import (
"fmt"
"google.golang.org/api/drive/v3"
"io"

"google.golang.org/api/drive/v3"
)

const DirectoryMimeType = "application/vnd.google-apps.folder"
Expand All @@ -15,7 +16,21 @@ type MkdirArgs struct {
Parents []string
}

func (args *MkdirArgs) normalize(drive *Drive) {
if len(args.Parents) > 0 {
var ids []string
finder := drive.newPathFinder()
for _, parent := range args.Parents {
id := finder.SecureFileId(parent)
ids = append(ids, id)
}
args.Parents = ids
}
}

func (self *Drive) Mkdir(args MkdirArgs) error {
args.normalize(self)

f, err := self.mkdir(args)
if err != nil {
return err
Expand Down

0 comments on commit dcfa3b9

Please sign in to comment.