add support list mimetype
This commit is contained in:
parent
51b3e634ab
commit
ee6b77b4fa
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue