迁移到 Drive API v3
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如果您目前使用的是 Drive API v2,可以迁移到 v3。
您应查看 V2 到 v3 参考,以获取版本之间所有资源差异的完整映射。
{drive_api_short} 版本针对每种语言的设置方式各不相同:
var DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"];
service = build('drive', 'v3', credentials=creds)
- 对于 Node.js,您可以在设置 google.drive 构造函数时定义版本。如需查看示例,请参阅 Node.js 快速入门。
const drive = google.drive({version: 'v3', auth});
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Migrate to Drive API v3\n\nIf you are currently using Drive API v2, you can migrate to v3.\n\nYou should review the [V2 to v3 reference](/workspace/drive/api/guides/v2-to-v3-reference) for a complete map of all resource differences between versions.\n\nThe {drive_api_short} version is set differently for each language:\n\n- For Java, you download the v3 library. See [Drive API client library for Java](https://github.com/googleapis/google-api-java-client-services/tree/main/clients/google-api-services-drive/v3).\n For an example, see [Java Quickstart](/workspace/drive/api/quickstart/java).\n\n- For JavaScript, you define the version with the Discovery docs URL. For an example,\n see [Browser Quickstart](/workspace/drive/api/quickstart/js).\n\n var DISCOVERY_DOCS = [\"https://www.googleapis.com/discovery/v1/apis/drive/v3/rest\"];\n\n- For Python, you specify the version when you build the service object. For an example, see [Python Quickstart](/workspace/drive/api/quickstart/python).\n\n service = build('drive', 'v3', credentials=creds)\n\n- For Node.js, you define the version when you set the google.drive constructor. For an example, see [Node.js Quickstart](/workspace/drive/api/quickstart/nodejs).\n\n const drive = google.drive({version: 'v3', auth});"]]