Method: files.delete
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ลบไฟล์ที่ผู้ใช้เป็นเจ้าของอย่างถาวรโดยไม่ย้ายไปที่ถังขยะ ดูข้อมูลเพิ่มเติมได้ที่ทิ้งหรือลบไฟล์และโฟลเดอร์
หากไฟล์อยู่ในไดรฟ์ที่แชร์ ผู้ใช้ต้องเป็นorganizer
ในโฟลเดอร์หลัก หากเป้าหมายเป็นโฟลเดอร์ ระบบจะลบรายการทั้งหมดที่ผู้ใช้เป็นเจ้าของซึ่งอยู่ในโฟลเดอร์นั้นด้วย
คำขอ HTTP
DELETE https://www.googleapis.com/drive/v3/files/{fileId}
URL ใช้ไวยากรณ์การแปลงรหัส gRPC
พารามิเตอร์เส้นทาง
พารามิเตอร์ |
fileId |
string
รหัสของไฟล์
|
พารามิเตอร์การค้นหา
พารามิเตอร์ |
supportsAllDrives |
boolean
แอปพลิเคชันที่ขอรองรับทั้งไดรฟ์ของฉันและไดรฟ์ที่แชร์หรือไม่
|
supportsTeamDrives (deprecated) |
boolean
เลิกใช้งานแล้ว: โปรดใช้ supportsAllDrives แทน
|
enforceSingleParent (deprecated) |
boolean
เลิกใช้งานแล้ว: หากรายการไม่ได้อยู่ในไดรฟ์ที่แชร์และมีการลบระดับบนสุดสุดท้ายของรายการ แต่ไม่ได้ลบรายการนั้นเอง ระบบจะวางรายการไว้ใต้รูทของเจ้าของ
|
เนื้อความของคำขอ
เนื้อหาของคำขอต้องว่างเปล่า
เนื้อหาการตอบกลับ
หากทำสำเร็จ เนื้อหาการตอบกลับจะเป็นออบเจ็กต์ JSON ที่ว่างเปล่า
ขอบเขตการให้สิทธิ์
ต้องใช้ขอบเขต OAuth อย่างใดอย่างหนึ่งต่อไปนี้
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.appdata
https://www.googleapis.com/auth/drive.file
ขอบเขตบางอย่างถูกจำกัดและต้องมีการประเมินความปลอดภัยเพื่อให้แอปของคุณใช้ขอบเขตเหล่านั้นได้ ดูข้อมูลเพิ่มเติมได้ที่คู่มือการให้สิทธิ์
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-27 UTC
[null,null,["อัปเดตล่าสุด 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)."]]