Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
¿Cómo elimino archivos de una carpeta compartida usando Google Drive V3?

Estoy tratando de crear una función que elimine archivos antiguos en una carpeta compartida de Google Drive de la siguiente manera:

 private async deleteExpiredFiles( dataType: DataType, folderId: string, expirationDate: string, ): Promise<void> { const { data: { files: filesToDelete }, } = await this.drive.files.list({ q: `'${folderId}' in parents and createdTime <= '${expirationDate}'`, supportsAllDrives: true, includeItemsFromAllDrives: true, }); if (!filesToDelete) { return; } await Promise.all( filesToDelete.map(async (file) => { if (!file.id) { return; } const permissionIds = await this.drive.permissions.list({ fileId: file.id, supportsAllDrives: true, }); if (!permissionIds.data.permissions) { return; } Promise.all( permissionIds.data.permissions.map(async (permission) => { if (!permission.id || !file.id) { return; } await this.drive.permissions.delete({ fileId: file.id, permissionId: permission.id, supportsAllDrives: true, }); }), ); }), ); }

Configuré todos los permisos en la carpeta de Google Drive y obtuve las credenciales correctas para la cuenta de servicio. Sin embargo, cuando intento ejecutar esto, aparece el siguiente error: GaxiosError: The authenticated user does not have the required access to delete the permission.

Puedo usar drive.files.list bien y ver los archivos, así como enumerar las identificaciones de permisos. Pero no me deja borrarlos. ¿Algún consejo?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

¡Resuelto!

En lugar de eliminar permanentemente los archivos. Simplemente los muevo a la papelera con el siguiente código:

 await this.drive.files.update({ fileId: file.id, requestBody: { trashed: true }, supportsAllDrives: true, });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!