RobinBobin / react-native-google-drive-api-wrapper

This wrapper facilitates the use of the Google Drive API in React Native projects.
110 stars 43 forks source link

Robin Bobin help me , How can I get all file of folder ? I try find resolve in document , but cannot do it. #42

Closed TienNguyen2803 closed 3 years ago

RobinBobin commented 3 years ago

I don't know what you mean by "I try find resolve in document"... what exactly are you trying to find, but this can be accomplished with listing files and specifying the parent folder id in the query string.

https://developers.google.com/drive/api/v3/search-files https://developers.google.com/drive/api/v3/ref-search-terms

TienNguyen2803 commented 3 years ago

@RobinBobin sorry, my English is a bit bad. I want to search for a list image in a folder. I have obtained the folder, next I want to search the list of images in a folder Help me pls.

const file = await googleDriver.files.list({
        q: new ListQueryBuilder()
          .e("mimeType", "application/vnd.google-apps.folder")
          .and()
          .e("name", "Software"),
      });

I search list items in a folder: fixed code

const file = await googleDriver.files.list({
        q: new ListQueryBuilder().in(
          "1M5BQ_NJVDrkeB5bi_uYmkGgi5qOmvi3N", //"folderID"
          "parents"
        ),
      });
RobinBobin commented 3 years ago

No worries, I'm here to help :) .

list() returns an object with several fields, one of which is files. It's an array of objects. This array is empty if nothing is found. Each object contains info about one of the found entries. You can get your folder id this way.

Then you issue another query, listing all the files in that folder (with the parents keyword) of the corresponding mime type (with the mimeType keyword).

BTW, MimeTypes have several handy constants defined.

TienNguyen2803 commented 3 years ago

Thanks, @RobinBobin. I have found listing items in a folder with query second!