Method: files.download
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.
Tải nội dung của một tệp xuống. Để biết thêm thông tin, hãy xem phần Tải và xuất tệp.
Các thao tác có hiệu lực trong 24 giờ kể từ thời điểm tạo.
Yêu cầu HTTP
POST https://www.googleapis.com/drive/v3/files/{fileId}/download
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
fileId |
string
Bắt buộc. Mã nhận dạng của tệp cần tải xuống.
|
Tham số truy vấn
Thông số |
mimeType |
string
Không bắt buộc. Loại MIME mà tệp sẽ được tải xuống. Bạn chỉ có thể đặt trường này khi tải tài liệu trên Google Workspace xuống. Để xem danh sách các loại MIME được hỗ trợ, hãy xem bài viết Xuất loại MIME cho tài liệu trên Google Workspace. Nếu bạn không đặt, thì tài liệu Google Workspace sẽ được tải xuống với loại MIME mặc định. Loại MIME mặc định có thể thay đổi trong tương lai.
|
revisionId |
string
Không bắt buộc. Mã phiên bản của tệp cần tải xuống. Bạn chỉ có thể đặt trường này khi tải tệp blob, Google Tài liệu và Google Trang tính xuống. Trả về INVALID_ARGUMENT nếu không hỗ trợ việc tải một phiên bản cụ thể của tệp xuống.
|
Nội dung yêu cầu
Nội dung yêu cầu phải trống.
Nội dung phản hồi
Nếu thành công, nội dung phản hồi sẽ chứa một phiên bản của Operation
.
Phạm vi uỷ quyền
Yêu cầu một trong các phạm vi OAuth sau:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/drive.readonly
Một số phạm vi bị hạn chế và yêu cầu bạn phải đánh giá bảo mật để ứng dụng của bạn có thể sử dụng các phạm vi đó. Để biết thêm thông tin, hãy xem Hướng dẫn uỷ quyền.
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-27 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-27 UTC."],[],[],null,["# Method: files.download\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nDownloads content of a file. Operations are valid for 24 hours from the time of creation.\n\n### HTTP request\n\n`POST https://www.googleapis.com/drive/v3/files/{fileId}/download`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|----------------------------------------------------|\n| `fileId` | `string` Required. The ID of the file to download. |\n\n### Query parameters\n\n| Parameters ||\n|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mimeType` | `string` Optional. The MIME type the file should be downloaded as. This field can only be set when downloading Google Workspace documents. See [files.export MIME types for Google Workspace documents](/drive/api/guides/ref-export-formats) for the list of supported MIME types. If not set, a Google Workspace document is downloaded with a default MIME type. The default MIME type might change in the future. |\n| `revisionId` | `string` Optional. The revision ID of the file to download. This field can only be set when downloading blob files, Google Docs, and Google Sheets. Returns `INVALID_ARGUMENT` if downloading a specific revision on the file is unsupported. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body contains an instance of [Operation](/workspace/drive/api/reference/rest/v3/operations#Operation).\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/drive`\n- `\n https://www.googleapis.com/auth/drive.file`\n- `\n https://www.googleapis.com/auth/drive.readonly`\n\nSome scopes are restricted and require a security assessment for your app to use them. For more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]