Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove a file that was previously added from Shared With Me to My Drive

Google Drive has a cool feature: one can add a file or folder from Shared With Me to My Drive.

enter image description here

Then I can delete this file from My Drive in the same manner (note that if I delete shared file in web version it won't go to Trash)

enter image description here

However, I am getting 403 Forbidden error while trying to delete this file using Google Drive API (because of insufficient permissions due to that I am not owner of this file). So, as one can see, this is not a simple Delete request. How can I implement this functionality?

like image 615
Oleksandr Zolotarov Avatar asked Mar 16 '15 18:03

Oleksandr Zolotarov


People also ask

Does removing a file from shared with me delete it?

In short, if you delete a file shared with you, it will only delete it from your drive, without any impact on other people's drives.

Why can't I delete shared files from Google Drive?

A Shared Drive with content in it cannot be deleted. And because every big company does dumb things, Google does not make this obvious. They simply remove the option from the menu vs greying it out with a note about the directory having to be empty for deletion … or really any clue at all would be nice.


2 Answers

Add to My Drive changes the parents collection for the item in question. To change this, you will want to unparent the item rather than delete.

Use the about.get call to retrieve the My Drive ID, then remove that ID from the list of parents in the file resource for the file/folder. Update the file with the new list of parents.

like image 182
Dan McGrath Avatar answered Oct 09 '22 19:10

Dan McGrath


A late answer, but I ran into this issue too. This happens because the file isn't actually copied, it's the same instance. If you remove it from My Drive, it will be removed from the Shared Drive too. And you may lack permission to remove it from the Shared Drive.

If you want to just remove it from My Drive: click on the file. In the right panel, under Details, there is a list of locations. At least the Shared Drive and My Drive is listed there. Click the X to remove it from My Drive, and it will disappear there while preserved on the Shared Drive.

like image 3
Jos van Egmond Avatar answered Oct 09 '22 20:10

Jos van Egmond