![](/img/trans.png)
[英]Google Client API v3 - update a file on drive using Python
[英]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.