Delete API
Last updated
This page explains how
DELETE /del/*path moves a file or folder into a date-bucketed trash, and how to restore it.Request
- # Delete a single file
- curl -X DELETE http://localhost:8080/del/blog/2025/ERftP1gTS7WCTeJ8_1744080848530.jpg
- # Delete an entire folder
- curl -X DELETE http://localhost:8080/del/blog/2025
*path is relative to storage/image/upload/ and may point at a file or a folder.Move Rules
| Step | Behavior |
|---|---|
| 1 | os.Stat confirms the target exists and checks whether it is a folder |
| 2 | Create storage/image/upload/.trash/YYYY-MM-DD/ (server local date) |
| 3 | Destination is .trash/YYYY-MM-DD/{file or folder name}; only the last path segment is kept, not the original parent path |
| 4 | A same-day name collision renames to {name}_{millisecond timestamp}{extension} |
| 5 | os.Rename moves it |
The trash sits under
upload/ but starts with .; Nginx's location ~ /\. denies any path containing /., so trash contents cannot be read through Nginx.Responses
| Status | Body | Case |
|---|---|---|
200 | {"success":1,"message":"move path to: ..."} | File moved |
200 | {"success":1,"message":"move folder to: ..."} | Folder moved |
400 | please assign a path first | Empty *path |
400 | path not found: ... | Target does not exist |
400 | can not create folder: ... / can not move file: ... | Trash creation or move failed |
408 | timed out | Exceeded 30 seconds |
The path in
message is the absolute path on the server.Restore and Cache
To restore, move the item from
.trash/YYYY-MM-DD/ back to its original location under storage/image/upload/. Deletion does not purge transformed caches, so existing size variants keep being served; see Caching Layers.