How to change permission of folder or file created in Google Drive using Google Drive Android API?

余生长醉 提交于 2019-12-10 22:08:21

问题


I'm using Google Drive Android API to store and share files and folders created. When I create a file/folder using Google Drive Android API,by default created file or folder is private (not shared publicly).

When I share the link of file/folder created to any user, that user needs to send email request for access to owner. So owner have to make file/folder public manually in Google Drive to prevent access requests.

Where as for Google Drive iOS API, when a file/folder is created, the file/folder created is by default public.

Another question I want to ask is, When I am querying list of folders in Root folder (with MIME_TYPE as application/vnd.google-apps.folder), the result is given with all folders. Where as using Google Drive iOS API, queryForFilesList() method returns only folders created by particular iOS app, not all folders in the root directory.

What I have to do to get this kind of result using Google Drive Android API or Google Drive REST API?


回答1:


Per DaImTo's comment:
You can use GDAA and REST together, I have a side-by-side CRUD implementations published here and here. You must be aware of a few things, though:

1/ The 'connect' in the GDAA is not aligned with the 'UserRecoverableAuthIOException' logic of the REST See init()/connect() combo in the two examples. Actually, you can use GDAA's 'connect' logic to do the authorization and then continue using the REST service. The 'UserRecoverableAuthIOException' should still be handled in case your user messes with the 'Settings > Manage Apps > Disconnect From Drive'. But then, your app is DOA anyway if it is under the FILE scope.

2/ The GDAA uses DriveId as a primary ID that is local to a device. It has access to the ResourceId (with some latency) that is primary ID in REST. The ResourceID is a system-wide ID that can be ported to different devices, systems. See here and here.

3/ The REST API is broader, the GDAA is build on top of it and has only a subset of functionality (no thumbnail link for instance). It supports FILE scope only (as opposed to DRIVE and FILE scopes of the REST).

4/ When you start mixing the 2 together, you will be exposed to latency/timing issues, since your app has full control over the REST's networking, whereas GDAA's synchronization is hidden with some vaguely documented sync methods.

If you look closer at the GDAA's architecture here (Lifecycle of a Drive file) , you will figure out potential pitfalls of mixing the two.

Good Luck



来源:https://stackoverflow.com/questions/30389302/how-to-change-permission-of-folder-or-file-created-in-google-drive-using-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!