Reputation: 21
I tried using the following code to delete files from google drive using python. But it is not working as the files are not getting cleared from drive after running this. uploading/downloading is getting done but deletion has this problem. I've been stuck at this point for a while and finding it hard to figure out.
def delete_file(service, file_id):
service.files().delete(fileId=file_id).execute()
The scope I'm using here is
SCOPE = 'https://www.googleapis.com/auth/drive'
Upvotes: 1
Views: 732
Reputation: 2635
I'm adding the answer here if someone will encounter this in the future:
You should clear the trash after deleting the file:
service.files().emptyTrash().execute()
Upvotes: 1