add support list mimetype

This commit is contained in:
namhq1989 2022-11-30 11:09:43 +07:00
parent 51b3e634ab
commit ee6b77b4fa
1 changed files with 8 additions and 3 deletions

View File

@ -45,12 +45,17 @@ func NewGoogleDrive(apiKey string) (*GoogleDrive, error) {
return &ggdrive, nil return &ggdrive, nil
} }
func (g GoogleDrive) GetFilesByFolderID(folderID string) ([]GoogleDriveFile, error) { func (g GoogleDrive) GetFilesByFolderID(folderID string, mimeType []string) ([]GoogleDriveFile, error) {
var ( var (
result = make([]GoogleDriveFile, 0) 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 { if err != nil {
err := fmt.Errorf("error when fetch folder %s: %s", folderID, err.Error()) err := fmt.Errorf("error when fetch folder %s: %s", folderID, err.Error())
return result, err return result, err