有没有人举例说明https://developers.google.com/drive/v2/reference/realtime/update?
以下代码中revision_body
和base_body
的内容如下:
1)字符串模型
2)列表模型
3)地图模型
file = service.realtime().update(
fileId=fileId,
media_body=revision_body,
baseRevision=base_body)
.execute()
答案 0 :(得分:1)
service.realtime().update(
fileId=fileId,
media_body=rev,
baseRevision=base
).execute()
其中rev
和base
如下所示:
<强>碱强>
base_body = service.realtime().get(fileId=fileId).execute()
base = MediaIoBaseUpload(
StringIO.StringIO(base_body),
'application/vnd.google-apps.drive-sdk'
)
<强>启:强>
rev_body = '{"appId":"...","revision":2,"data":{"id":"root","type":"Map","value":{"text":{"id":"%s","type":"EditableString","value":"Hello Realtime World!"}}}}' % randomString(12)
rev = MediaIoBaseUpload(StringIO.StringIO(rev_body), 'application/vnd.google-apps.drive-sdk')
其中randomString(n)
:
def randomString(length):
return ''.join(random.choice(string.letters + string.digits + '_-') for i in range(length))
```