如何使用 REST API 将新修订上传到 Google 驱动器中的特定文件?

How can I upload a new revision to an specific file in Google Drive using the REST API?

我有时会阅读官方文档、博客和谷歌搜索,但都没有成功。 Google 此处提供驱动器文档:https://developers.google.com/drive/v2/reference/revisions/patch 根据文档,可用的休息端点是 "delete"、"get"、"list"、"patch" 和 "update".

我正在尝试将 修订版 添加到 Google 驱动器中已存在的文件。

作为一个问题条件,我不应该使用和SDK。

只是为了说明这个想法,这是我用来上传文件的 post 请求:

POST /upload/drive/v2/files?uploadType=media HTTP/1.1
Host: www.googleapis.com
Content-Length: number_of_bytes_in_file
Authorization: Bearer your_auth_token

如有任何帮助,我们将不胜感激。谢谢!

我找到了这个 https://developers.google.com/drive/v2/reference/files/update 更新文档。那里解释了如何使用 pinnednewRevision 可选参数。

PUT https://www.googleapis.com/upload/drive/v2/files/{fileId}&pinned=true

我在请求正文中发送了新文件内容(就像上传新文件一样)。如果您想要自定义行为(例如,您可以使用另一个端点来更新文件的元数据),您可以阅读文档。