从Google驱动器文件元数据中的属性列表中修补/更新特定键值

时间:2019-03-19 08:45:09

标签: google-drive-api

因此,我从驱动器中获得了这些属性集。现在,我想从列表中更新特定的键值对,但似乎Google驱动器api补丁需要添加另一组属性。

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

"properties":[{"visibility":"PUBLIC","kind":"drive#property","etag":"\"LIfz66WQFJW5vkUY9zfkRsF1GXw/v2QgQs4jWTpXupDwCreIaEqwUB0\"","value":"content_article","key":"TAG_SYSTEM_NAME"},{"visibility":"PUBLIC","kind":"drive#property","etag":"\"LIfz66WQFJW5vkUY9zfkRsF1GXw/_gkHHQjcY8SsrxQ5YfkEKLgJd78\"","value":"content","key":"TAGSET_SYSTEM_NAME"},{"visibility":"PUBLIC","kind":"drive#property","etag":"\"LIfz66WQFJW5vkUY9zfkRsF1GXw/zlFg7XikUX87CoN8nlKkxomLGZA\"","value":"1204622","key":"ID"},{"visibility":"PUBLIC","kind":"drive#property","etag":"\"LIfz66WQFJW5vkUY9zfkRsF1GXw/UP9PtLc4WE_Q7ADNu0V-OSG22QQ\"","value":"1037753","key":"BRIDGE_KM_CON_TAG_GROUP_ID"},{"visibility":"PUBLIC","kind":"drive#property","etag":"\"LIfz66WQFJW5vkUY9zfkRsF1GXw/sznUVWiSHbLf7-HDsqvfCqoFEpg\"","value":"Content Categories","key":"TAGSET_DISPLAY_NAME"},{"visibility":"PUBLIC","kind":"drive#property","etag":"\"LIfz66WQFJW5vkUY9zfkRsF1GXw/6F3Yo9Sj6aeMw5BlH7kKSfXcH9A\"","value":"Y","key":"is_featured"},{"visibility":"PUBLIC","kind":"drive#property","etag":"\"LIfz66WQFJW5vkUY9zfkRsF1GXw/VStyd4kXuLSIRpFXYvRPMBuYdDU\"","value":"Article","key":"TAG_DISPLAY_NAME"},{"visibility":"PUBLIC","kind":"drive#property","etag":"\"LIfz66WQFJW5vkUY9zfkRsF1GXw/PglkjP6d-2vMgJrovo3b02atA3g\"","value":"KM1100996","key":"kmid"}]

1 个答案:

答案 0 :(得分:0)

除非您有充分的理由使用v2 API(并且确实存在),否则您应该使用https://developers.google.com/drive/api/v3/reference/files/update

至少对于v3,您在PATCH正文中提供的任何属性都将与现有属性合并。

所以...

  

起始文件:{foo:1}

     

然后补丁:{bar:2}

     

叶子文件:{foo:1,bar:2}

要删除属性,请使用空值对其进行修补

  

开始文件:{foo:1,bar:2}

     

然后补丁:{bar:null}

     

离开文件:{foo:1}