Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete a Google document permanently

I am trying to delete a Google document by using Java APIm it works fine but the document is getting settled in the trash folder. I want the document to get deleted permanently even from trash. Can someone please suggest me a solution on how to work on this?This is the code that I've been using to delete the document.

    DocsService docsService = new DocsService(domain);
    URL docURL = new URL("https://docs.google.com/feeds/default/private/full/"+resourceId+"?xoauth_requestor_id=" + loginUser);//No I18N
    DocumentListEntry sd=docsService.getEntry(docURL, DocumentListEntry.class);
    sd.delete();
like image 782
Jagadeesh Avatar asked Feb 26 '26 14:02

Jagadeesh


1 Answers

Deleting a file permanently is equivalent to sending a DELETE request to the file's edit URL with the query parameter "delete=true" (skip trash):

DocsService docsService = new DocsService(domain);
URL docURL = new URL(
    "https://docs.google.com/feeds/default/private/full/"+resourceId+"?xoauth_requestor_id=" + loginUser + "&delete=true");
docsService.delete(docURL, "<ENTRY'S ETAG>");

If you want to by-pass the "etag" check, you can pass the special value "*".

like image 90
Alain Avatar answered Feb 28 '26 23:02

Alain



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!