从与我共享的文件夹中完全删除文件 [英] Delete a file completely from shared with me folder

查看:156
本文介绍了从与我共享的文件夹中完全删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除使用Google Drive API与我共享的文件,但是由于我不是该文件的所有者,因此出现权限错误.我在网上查看了此内容,并找到了

I am trying to delete a file which is shared with me using Google Drive API but since I'm not the owner of the file I'm getting a permission error. I looked the on the web and find this solution. I implemented the solution as below:

About about = service.about().get().execute();
String rootId = about.getRootFolderId();
service.parents().delete(fileId, rootId).execute();

但是,我无法使用此代码删除文件.它没有给出任何错误,但我仍然可以在Google驱动器中看到该文件.

However, I cannot delete the file with this code. It doesn't give any error but I can still see the file in my google drive.

PS:我检查了 fileId 参数,它引用了正确的文件.

PS: I checked the fileId parameter and it's referencing to the correct file.

推荐答案

对不起,我不知道Java,因此无法提供任何代码示例.

Sorry I don't Know java so couldn't provide any code sample.

因此,在Google Drive API V3中,您不再可以使用About Resource通过 getRootFolderId 方法获取根文件夹ID.

So In Google Drive API V3 you can no longer get the root folder Id by getRootFolderId method using About Resource.

相反,您需要使用 file.get 方法,使用 root (而不是文件ID)作为 fileId ,并请求其他字段 id (传递?fields = id )以获取rootFolderId.

Instead you need to use file.get method, use root (instead of your file Id) as the fileId and request additional field id (passing ?fields=id) to get the rootFolderId.

在Drive API V3中,它们默认已停止返回完整资源.因此,如果您使用任何与V2相关的代码,请务必小心.

In the Drive API V3 they have stopped returning full resource by default. So be careful if you use any code related to V2.

在Google驱动器api官方迁移文档中查看字段部分

Check out the Fields Section in google drives api official migration document.

希望这会有所帮助.

谢谢

这篇关于从与我共享的文件夹中完全删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆