Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete a file using Google Drive API

The problem is similar to this post(Documents deleted using Google Docs API still visible in Google Drive can't really get it working with the solutions suggested. When we delete a file using delete() function, whether or not the file got deleted is not the question here, the problem is the file will always be visible in the web browser and can not even be removed manually. I was wondering is there a way to delete the file but also make it disappear in the web UI?

Thanks a lot.

like image 891
user1935724 Avatar asked Oct 19 '25 00:10

user1935724


1 Answers

In the v3 API, you should be able to delete a file by using its id. Don't forget to call execute() on the Delete object returned by service.files().delete().

import com.google.api.services.drive.model.*;
import com.google.api.services.drive.Drive;

Drive service = ...;

com.google.api.services.drive.model.File file = ...;

service.files().delete(file.getId()).execute();
like image 50
Mike Spear Avatar answered Oct 22 '25 06:10

Mike Spear



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!