# Delete API

This page explains how `DELETE /del/{path}` moves files or folders into the trash, and how to restore them.

## Request

| Item | Value |
|---|---|
| Method | `DELETE` |
| Path | `/del/{path}`, where `{path}` is a file or folder under `storage/image/upload/`; a trailing `/` is stripped |
| Body | Not needed |

## Move Rules

| Rule | Behavior |
|---|---|
| Destination | `storage/image/upload/.trash/{YYYY-MM-DD}/{last segment}` |
| Date | UTC date (`toISOString()`) |
| Name collision | When the destination exists, `_{millisecond timestamp}` is appended; files keep their extension (`a_1791311009904.jpg`), folders get it appended directly (`x_1791311009904`) |

## Responses

| Status | Type | Body |
|---|---|---|
| `200` | JSON | `{ "success": 1, "message": "檔案已移動至垃圾桶: {absolute server path}" }` |
| `200` | JSON | Folder: `檔案夾已移動至垃圾桶: {absolute server path}` |
| `400` | Text | `未指定檔案/檔案夾` |
| `404` | Text | `檔案/檔案夾不存在` |
| `500` | Text | System error message |

## Examples

```bash
# Delete a file
curl -fsS -X DELETE \
  http://localhost:8080/del/blog/2025/ERftP1gTS7WCTeJ8_1744080848530.jpg

# Delete a whole folder
curl -fsS -X DELETE http://localhost:8080/del/blog/2025
```

## Restore

Move the item from the trash back to its original path (with Docker Compose the host path is `./image/`):

```bash
mv ./image/upload/.trash/2026-10-06/ERftP1gTS7WCTeJ8_1744080848530.jpg \
   ./image/upload/blog/2025/
```

