javascriptgoogle-drive-apidrivegoogle-api-js-clientrecycle-bin

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


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.


Solution

  • My working code is:

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

    Regards.