Google Drive SDK API:如何将文件从root移动到文件夹?

lan*_*boy 4 google-drive-api

如何使用Google Drive SDK API将文件从root移动到文件夹?

我试过这个,但它永远不会奏效!

1)将文件ID插入文件夹.
方法: https ://developers.google.com/drive/v2/reference/children/insert
结果:文件可以插入文件夹,但文件也会显示在根目录中.

2)从父项中删除文件ID.
方法: https ://developers.google.com/drive/v2/reference/parents/delete
结果:一个奇怪的结果.它应该删除父文件,但这删除了文件夹中的子文件.

有什么帮助吗?

Nic*_*ong 5

更简单的方法是使用patch将parents字段更新为新文件夹的id.

https://developers.google.com/drive/v2/reference/files/patch