PutBucketTrash
Updated at:2025-11-03
API description
This API activates the Bucket Trash feature. The user must own the source bucket with FULL_CONTROL permission and also be the owner of the target bucket.
Request
-
Request syntax
Plain Text1 PUT /?trash HTTP/1.1 2 Host: <BucketName>.bj.bcebos.com 3 Date: <Date> 4 Authorization: <AuthorizationString> 5 Content-Type: application/json 6 Content-Length: <ContentLength> -
Request headers
No special header parameters
-
Request elements
| Name | Description |
|---|---|
| trashDir | The trash directory name, with a length limit. Optional. It defaults to .trash if empty. |
Plain Text
1> **Notes**:
2>
3> 1. Enabling the trash function will rename the original directory.
4>
5> 2. "trashDir" can only include letters, numbers, Chinese characters, underscores (_), hyphens (-), and decimal points (.). Using '/' will trigger an error.
6>
7> 3. For buckets with the trash feature enabled, deleted objects are moved to the trash (the object's full name in the trash is: trashDir + '/' + the old object name). Objects in buckets without this feature, or those deleted directly from the trash, will be permanently removed.
8>
9> 4. Files in the archive storage class do not support the Bucket Trash feature and will be deleted immediately when removed.
Response
| Result | http status | error code | Description |
|---|---|---|---|
| Json format error | 400 | MalformedJSON | - |
| The trash directory name is too long | 400 | EntityTooLarge | Not exceeding 1024 bytes |
| The trash directory contains invalid characters | 400 | InvalidTrashDirectoryName | It can only contain letters, numbers, Chinese characters, underscores (_), hyphens (-), and decimal points (.). |
| The bucket does not exist | 404 | NoSuchBucket | - |
| No permission | 403 | AccessDenied | Only the bucket owner with FULL_CONTROL permission can perform this operation. |
Example
-
Request example
Plain Text1PUT /?trash HTTP/1.1 2Host: bucket.bj.bcebos.com 3x-bce-date: date 4Content-Length: request-body-length 5Content-Type: application/json; charset=utf-8 6Authorization: AuthorizationString 7{ 8"trashDir": "trashDirName" 9} -
Response example
Plain Text1HTTP/1.1 200 OK 2x-bce-request-id: 4db4b34d-653d-4d9a-b49b-3049ca786409 3Date: Wed, 31 May 2017 08:34:40 GMT 4Server: BceBos
