cannot get folderId that i just created on google drive

血红的双手。 提交于 2019-11-26 11:56:23
seanpj

Do not mix DriveId with ResourceId. Both look like strings, but DriveId is different from ResourceId. See SO 21800257. Also, ResourceId is not immediately available, see SO 22874657.

DriveId usually looks like:

"DriveId:CAESHDBCMW1RVblahblahblahblahMYjAUgssy8yYFRTTNKRU55"

whereas ResourceId is more like:

"UW2ablahblaghblahNy00Ums0B1mQ"

UPDATE:

Since so many developers fight this issue, I'll try to elaborate as deep as my knowledge allows me to.

     Google Drive             Google Play Svcs      YourApp
   (up in the cloud)         (on your device)      (on your device)
  +--------------------+      +--------------+     +--------------+         
  | 'id' (RESTful API) | - - -> ResourceId  - - - -> ResourceId   |
  +--------------------+      |  DriveId    - - - -> DriveId      |
                              +--------------+     +--------------+

What I'm trying to convey with the artistic expression above is:

  • When you create a drive object (folder/file) on your device, GooPlaySvcs will give you the DriveId
  • You can use this DriveId for local communication with GooPlaySvcs, you can cache it, etc.
  • Per Daniel's comment in SO 21800257 (link above), do not rely on DriveId to be a constant string, it supposedly changes upon the object being committed. Use DriveId.equals() (I did not test that)
  • Anytime you step outside of the local device (Drive web interface, other apps, YourApp on a different device), you need to use ResourceId, which is the only unique ID on the Drive (up in the cloud :-).
  • The ResourceId is available to your AFTER GooPlaySvcs commit the object to the Drive. There are ways to force it, but it is a different story (search for requestSync()).
  • If you decide to grab the ResourceId and use it for RESTfull calls (delete/trash), be aware of the fact that Google Play Services propagates its changes on a schedule you don't have control over (so it seems, see the requestSync() issue again), and your REST/GDAA fight can cause damage to your data. GDAA(GooPlayServices) may not be aware of your REST changes for a while. You have to manage the synchronization yourself. I admit I failed miserably when I tried.

    Good Luck

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