I´m writing a small script in python 3.5.2 with pydrive 1.2.1 and I need to be able to delete a file which is not stored locally in my computer, but in my account of Google Drive. The docs only show how to delete a file you previously created, not one which is already stored on the drive. Is deleting an existing file actually possible with pydrive? if so, how?
You can permanently delete an individual file or empty your entire trash. After you delete a file permanently, anyone you've shared the file will lose access to it. If you want others to be able to view the file, you can transfer ownership to someone else.
Open your Google Drive account and check for the files in My Drive and Shared Drive. If the files are located in Shared Drive then they cannot be deleted. Else if the file is in My Drive then try using some other browse or clear cache and try again.
Show activity on this post. Editors in a shared folder in Google Drive can do these things: They can move these files, even out of the shared folder.
From the docs seems that drive.CreateFile()
create only a reference to a file, this can be local or remote.
As you can se here drive.CreateFile()
is used to download a remote file.
I believe that something like this should do the job:
# Initialize GoogleDriveFile instance with file id.
file1 = drive.CreateFile({'id': <file-id>})
file1.Trash() # Move file to trash.
file1.UnTrash() # Move file out of trash.
file1.Delete() # Permanently delete the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With