diff --git a/google_drive.go b/google_drive.go index 7ae517a..28f19c6 100644 --- a/google_drive.go +++ b/google_drive.go @@ -45,18 +45,23 @@ func NewGoogleDrive(apiKey string) (*GoogleDrive, error) { return &ggdrive, nil } -func (g GoogleDrive) GetFilesByFolderID(folderID string) ([]GoogleDriveFile, error) { +func (g GoogleDrive) GetFilesByFolderID(folderID string, mimeType []string) ([]GoogleDriveFile, error) { var ( result = make([]GoogleDriveFile, 0) ) - res, err := getfilelist.Folder(folderID).Fields("files(name,id)").Do(g.svc) + chain := getfilelist.Folder(folderID).Fields("files(id,name)") + if len(mimeType) > 0 { + chain.MimeType(mimeType) + } + + res, err := chain.Do(g.svc) if err != nil { err := fmt.Errorf("error when fetch folder %s: %s", folderID, err.Error()) return result, err } - // if there is more than 1 subfolder + // if there is more than 1 sub folder if len(res.FileList) != 1 { err := fmt.Errorf("folder %s have more than 1 subfolder", folderID) return result, err