3

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.

Andres Duarte
  • 3,166
  • 1
  • 7
  • 14
  • I think that your script works. So in order to correctly understand your situation, can you provide the detail information about ``doesnt work`` and the whole script for replicating your issue? By adding more information, users can think of your solution. Of course, please remove your personal information. – Tanaike Jul 01 '19 at 22:26
  • I replicated the request you're doing and is working exactly as you have it. Can you add the error message and give details of your steps? Please. – Andres Duarte Jul 02 '19 at 13:02
  • Agreed, this doesn't seem to work. It responds `OK` but doesn't actually delete the file. – z0r Dec 03 '19 at 04:39

2 Answers2

0

My working code is:

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

Regards.

0

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
  }
});
mattwad
  • 1,743
  • 17
  • 13