Sanjay Vamja
Sanjay Vamja

Reputation: 2255

How to move file to trash using NodeJS and Google Drive API v3

How to move a file to trash using NodeJS and Google Drive API v3. Below lines are NOT working:

await drive.files.update({ fileId, trashed: true }); // not working
await drive.files.update({ fileId },  { trashed: true }); // not working

Upvotes: 3

Views: 904

Answers (1)

Tanaike
Tanaike

Reputation: 201593

I believe your situation and goal as follows.

  • You want to move a file to the trash box using Drive API v3 with googleapis with Node.js.
  • drive can be used for using the method of "Files: update" of Drive API.

For this, how about this modification? In this case, please include the request body to requestBody or resource as follows.

Modified script:

await drive.files.update({ fileId, requestBody: { trashed: true } });

or

await drive.files.update({ fileId, resource: { trashed: true } });

References:

Upvotes: 4

Related Questions