繁体   English   中英

如何使用Google云端硬盘v3更新文件appProperty

[英]How to update File appProperties using Google Drive v3

上载文件且知道file_id

media_body = MediaFileUpload(filepath, mimetype=mimetype)
body = {'name': os.path.basename(filepath), 'appProperties':{'my_key': 'my_value'}}
file = drive_service.files().create(body=body, media_body=media_body, fields='id, appProperties').execute()
file_id = file['id']

如何使用v3修改文件的appProperties

有一篇Google Drive API v3迁移文章,可用于了解文档中未涵盖的内容。 这篇文章的“ 废纸//更新”部分讨论了Google Drive API v3中的update功能。 但是它是用Java而不是Python编写的。 它建议使用一个空的File对象: File newContent = new File();

这次有关PHP的另一篇文章也提到了update方法和这种空文件方法: 如何更新Google Drive v3 PHP中的文件

如果有人在这里使用两个Python代码段来引导我朝着正确的方向发展,我将不胜感激。

接下来的样本怎么样? 为了更新appProperties ,可以使用drive.files.update。 详细信息在这里

示例脚本:

body = {'appProperties': {'my_key': 'updated_my_value'}}
updated_file = drive_service.files().update(
    body=body,
    fileId="### file id ###",
    fields='id, appProperties'
).execute()

如果我误解了您的问题,对不起。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM