Mẫu API Google Drive
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Phần này cung cấp các mẫu cho API Google Drive.
Để xem các video giới thiệu về Drive API, hãy xem thư viện video Drive API.
Google lưu trữ các mẫu sau trên GitHub. Bạn có thể phân nhánh các kho lưu trữ này và sử dụng mã làm tài liệu tham khảo cho các dự án của riêng mình.
Bộ chọn của Google
Mẫu mã Google Picker cho biết cách sử dụng một bộ chọn hình ảnh hoặc trang tải lên mà người dùng có thể mở từ một nút trong ứng dụng web.
Để xem hoặc tải nguồn xuống, hãy truy cập vào Google Picker trên kho lưu trữ GitHub.
Mở và lưu tệp bằng Quickeditors
Mã mẫu Quickeditors này cho biết cách mở và lưu tệp bằng Drive API.
Mỗi ví dụ dành riêng cho nền tảng Drive đều phản ánh một ứng dụng mẫu duy nhất: một trình chỉnh sửa văn bản, được gọi là Quickeditor, có khả năng chỉnh sửa các tệp trên Drive có loại MIME là text/*
. Phiên bản web triển khai 2 trường hợp sử dụng cơ bản của Drive:
Quy trình cho cả hai trường hợp sử dụng đều tương tự nhau. Drive chuyển hướng người dùng đến ứng dụng sau khi người dùng chọn ứng dụng đó trong trình đơn tạo hoặc trình đơn theo bối cảnh của một tệp có loại MIME đã đăng ký.
Để xem hoặc tải nguồn xuống, hãy truy cập vào Drive Quickeditors trên kho lưu trữ GitHub.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],null,["# Google Drive API samples\n\nThis section provides samples for Google Drive API.\n\nFor introductory videos about Drive API, see the [Drive API\nvideo library](/workspace/drive/api/guides/videos).\n\nGoogle hosts the following samples on GitHub. You can fork these repositories\nand use the code as a reference for your own projects.\n\nGoogle Picker\n-------------\n\nThe [Google Picker code sample](/workspace/drive/picker/guides/sample) shows how to use\nan image selector or upload page that users can open from a button in a web app.\n\nTo view or download the source, visit\n[Google Picker](https://github.com/googleworkspace/browser-samples/tree/main/drive/picker)\non the GitHub repository.\n\nOpen and save files with Quickeditors\n-------------------------------------\n\nThis Quickeditors code sample shows how to open and save files with the\nDrive API.\n\nEach of the Drive platform-specific examples reflects a single\nsample app: a text editor, called a Quickeditor, capable of editing\nDrive files with the MIME type `text/*`. The [web\nversion](https://github.com/googleworkspace/drive-quickeditors/tree/main/web)\nimplements two fundamental Drive use cases:\n\n- [Integrate with Drive UI's \"New\" button](/workspace/drive/api/guides/integrate-create)\n- [Integrate with Drive UI's \"Open with\" context menu](/workspace/drive/api/guides/integrate-open)\n\nThe flow for both use cases is similar. Drive redirects a user to\nthe app after the user selects it from the create menu or the context menu of a\nfile with a registered [MIME type](/workspace/drive/api/guides/mime-types).\n\nTo view or download the source, visit [Drive\nQuickeditors](https://github.com/googledrive/web-quickeditor) on the GitHub\nrepository.\n\nRelated topics\n--------------\n\n- [The Google Picker API](/workspace/drive/picker/guides/overview)\n- [Drive UI integration overview](/workspace/drive/api/guides/about-apps)"]]