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

drive.files.safeCreateFolder replacement? #48

Closed jebuth closed 3 years ago

jebuth commented 3 years ago

how can we create new folders in drive? previously this was the method:

let response = await GDrive.files.safeCreateFolder({ name: GLOBAL.GOOGLE_DRIVE.TARGET_FOLDER_NAME, parents: ['root'], });

RobinBobin commented 3 years ago
gdrive.files.newMetadataOnlyUploader()
  .setRequestBody({
    name: "folder",
    mimeType: MimeTypes.FOLDER,
    parents: ["root"]
  })
  .execute()

creates a folder.

gdrive.files.createIfNotExists({
  q: new ListQueryBuilder()
    .e("name", "condition_folder")
    .and()
    .e("mimeType", MimeTypes.FOLDER)
    .and()
    .in("root", "parents")
},
  gdrive.files.newMetadataOnlyUploader()
    .setRequestBody({
      name: "condition_folder",
      mimeType: MimeTypes.FOLDER,
      parents: ["root"]
    }
  )
)

if it doesn't exist.

jebuth commented 3 years ago

Thank you!

RobinBobin commented 3 years ago

You're welcome.