Google Drive PHP API: How do I get all files in a folder created by my app, placed there by the user or another app

时间:2015-09-11 15:14:51

标签: php google-drive-api

So Google Drive has a lot of security, which is a good thing. By default, my app can only get the files it has itself created on the user's drive. However, I also need to be able to retrieve all files placed by the user (or another app) in one of the folders that my app created.

Example:

  • My app creates a folder called "Stuff"
  • Now the user manually uploads a file called "test.txt" and places it in "Stuff".
  • My app can't see this file, even though the app created the folder that the file is in. This is what I'd like to fix.

In addition, I have seen code on stackoverflow and other places which gives my app access to the user's ENTIRE google drive, but I'd like to avoid doing that. I only need access to the files created inside folders created by my app, not everything. Besides, the code that I found about this was all from 2012 or earlier and doesn't work anymore due to undocumented changes in the PHP API.

Any help would be appreciated.

2 个答案:

答案 0 :(得分:0)

似乎不可能。我被迫让我的应用程序访问用户的整个驱动器。这是相关的代码:

$client->setScopes(implode(' ', array(
    Google_Service_Drive::DRIVE,
)));

如果有人有更好的解决方案,我很乐意听到。

答案 1 :(得分:0)

用户需要使用您的应用打开新上传的文件,以便您可以访问它。我遇到了类似的问题并使用了此处描述的解决方法:Drive API for Android unable to access the file created by same App