Method: files.delete
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.
Xoá vĩnh viễn một tệp thuộc quyền sở hữu của người dùng mà không chuyển tệp đó vào thùng rác. Để biết thêm thông tin, hãy xem bài viết Chuyển vào thùng rác hoặc xoá tệp và thư mục.
Nếu tệp thuộc về một bộ nhớ dùng chung, thì người dùng phải có quyền organizer
đối với thư mục mẹ. Nếu đích đến là một thư mục, thì tất cả các thư mục con thuộc sở hữu của người dùng cũng sẽ bị xoá.
Yêu cầu HTTP
DELETE https://www.googleapis.com/drive/v3/files/{fileId}
URL sử dụng cú pháp Chuyển mã gRPC.
Tham số đường dẫn
Thông số |
fileId |
string
Mã nhận dạng của tệp.
|
Tham số truy vấn
Thông số |
supportsAllDrives |
boolean
Liệu ứng dụng yêu cầu có hỗ trợ cả Drive của tôi và bộ nhớ dùng chung hay không.
|
supportsTeamDrives (deprecated) |
boolean
Không dùng nữa: Thay vào đó, hãy sử dụng supportsAllDrives .
|
enforceSingleParent (deprecated) |
boolean
Không dùng nữa: Nếu một mục không nằm trong bộ nhớ dùng chung và mục chính gần đây nhất của mục đó bị xoá nhưng bản thân mục đó không bị xoá, thì mục đó sẽ được đặt trong thư mục gốc của chủ sở hữu.
|
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, phần nội dung phản hồi sẽ là một đối tượng JSON trống.
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.appdata
https://www.googleapis.com/auth/drive.file
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.delete\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\nPermanently deletes a file owned by the user without moving it to the trash. If the file belongs to a shared drive, the user must be an `organizer` on the parent folder. If the target is a folder, all descendants owned by the user are also deleted.\n\n### HTTP request\n\n`DELETE https://www.googleapis.com/drive/v3/files/{fileId}`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|----------|------------------------------|\n| `fileId` | `string` The ID of the file. |\n\n### Query parameters\n\n| Parameters ||\n|----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `supportsAllDrives` | `boolean` Whether the requesting application supports both My Drives and shared drives. |\n| `supportsTeamDrives` **(deprecated)** | `boolean` Deprecated: Use `supportsAllDrives` instead. |\n| `enforceSingleParent` **(deprecated)** | `boolean` Deprecated: If an item is not in a shared drive and its last parent is deleted but the item itself is not, the item will be placed under its owner's root. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body is an empty JSON object.\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.appdata`\n- `\n https://www.googleapis.com/auth/drive.file`\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)."]]