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


  1. # Delete a single file
  2. curl -X DELETE http://localhost:8080/del/blog/2025/ERftP1gTS7WCTeJ8_1744080848530.jpg
  3. # Delete an entire folder
  4. 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


StepBehavior
1os.Stat confirms the target exists and checks whether it is a folder
2Create storage/image/upload/.trash/YYYY-MM-DD/ (server local date)
3Destination is .trash/YYYY-MM-DD/{file or folder name}; only the last path segment is kept, not the original parent path
4A same-day name collision renames to {name}_{millisecond timestamp}{extension}
5os.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


StatusBodyCase
200{"success":1,"message":"move path to: ..."}File moved
200{"success":1,"message":"move folder to: ..."}Folder moved
400please assign a path firstEmpty *path
400path not found: ...Target does not exist
400can not create folder: ... / can not move file: ...Trash creation or move failed
408timed outExceeded 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.
中文