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

Fetching list of files in a folder #61

Closed SushiTheory closed 2 years ago

SushiTheory commented 2 years ago

Hello Robin

I am stiill unable to fetch the files from a specific folder even after replacing root with the folder i wanted.

this is the function i called

await gdrive.files.list({ q: new ListQueryBuilder() .e("mimeType", MimeTypes.FOLDER) .and() .in("Java", "parents") })

but the result i get is [HttpError: { "error": { "errors": [ { "domain": "global", "reason": "notFound", "message": "File not found: .", "locationType": "parameter", "location": "fileId" } ], "code": 404, "message": "File not found: ." } } ]

RobinBobin commented 2 years ago

.in("Java", "parents")

I'm pretty sure the ID of the folder must be specified, not the name.

Btw, you're listing folders, not files (.e("mimeType", MimeTypes.FOLDER)).

SushiTheory commented 2 years ago

Yupp that fixed it, replacing "root" with the full ID gets the job done. Thank you so much!!!

RobinBobin commented 2 years ago

You're welcome, glad you sorted it out. Would you mind closing the issue if the question is solved?

RutvikUnjiya commented 2 years ago

Hello Robin, How Can I Create Specific Folder on Google Drive and get that Folder's ID? Please Help me

RobinBobin commented 2 years ago

Hello RutvikUnjiya,

Something like

await gdrive.files.newMetadataOnlyUploader()
  setRequestBody({
    name: "Folder",
    mimeType: MimeTypes.FOLDER,
    parents: ["root"]
  })
  .execute()

Please have a look at the docs to get the created folder id from the result.