how to move file to trash in drive api v3 in javascript?

Viewed 533

I would like to use the gapi js SDK client to trash a file. But i cannot find a working example. I do not know where to place the trashed attribute in the call

gapi.client.drive.files.update({fileId: 'someId', trashed: true}); doesnt work.

2 Answers

My working code is:

var id = "someId";
gapi.client.drive.files.update({
                "fileId": id,
                "trashed": true
}).then(function (evt) {
  //someAction after delete file
});

Regards.

The above examples didn't work for me, but I found a more recent answer that does:

gapi.client.drive.files.update({
  fileId: 'someId',
  responseBody: {
    trashed: true
  }
});
Related