Files
fm_be/docs/file-manager-delete-store.md
2026-07-16 22:16:45 +07:00

242 lines
4.4 KiB
Markdown

# File Manager
# Delete, Restore, Purge
## Ringkasan Endpoint Utama
1. `DELETE /api/v1/file-manager/delete` untuk soft delete bulk (file/folder)
2. `PATCH /api/v1/file-manager/restore` untuk restore bulk (file/folder) ke lokasi asal
3. `DELETE /api/v1/file-manager/purge-delete` untuk hard delete bulk (file/folder)
4. `GET /api/v1/file-manager/trash/get-all` untuk list trash merged
## Catatan Kontrak
1. Tidak ada endpoint delete single.
2. Tidak ada endpoint restore single.
3. Gunakan endpoint bulk untuk delete/restore/purge.
## Step 1 - Soft Delete Node (Bulk)
### Endpoint
- `DELETE /api/v1/file-manager/delete`
### Tujuan
- soft delete file/folder (masuk trash)
- jika folder di-delete, subtree (child folder + child file) ikut ke-trash
### Contoh request
```json
{
"data": [
{ "uuid": "folder-uuid" },
{ "uuid": "file-uuid" }
]
}
```
### Contoh response
```json
{
"data": [
{
"index": 0,
"success": true,
"resource": {
"type": "file_manager_delete_result",
"id": "folder-uuid",
"attributes": {
"node_type": "folder",
"status": "trashed"
}
}
},
{
"index": 1,
"success": true,
"resource": {
"type": "file_manager_delete_result",
"id": "file-uuid",
"attributes": {
"node_type": "file",
"status": "trashed"
}
}
}
],
"meta": {
"total": 2,
"success": 2,
"failed": 0,
"partial_success": false
}
}
```
## Step 3 - Lihat Trash
### Endpoint
- `GET /api/v1/file-manager/trash/get-all`
### Tujuan
- menampilkan data trash merged (folder + file)
### Contoh response
```json
{
"data": [
{
"type": "file_manager_trash_node",
"id": "folder-uuid",
"attributes": {
"node_type": "folder",
"name": "Documents",
"path_cache": "/Documents",
"trashed_at": "2026-04-01T10:00:00Z"
}
},
{
"type": "file_manager_trash_node",
"id": "file-uuid",
"attributes": {
"node_type": "file",
"name": "LOGO.png",
"extension": "png",
"size_bytes": 100988,
"mime_type": "image/png",
"trashed_at": "2026-04-01T10:00:00Z"
}
}
],
"meta": {
"page_number": 1,
"page_size": 20,
"folders": 1,
"files": 1,
"total": 2
}
}
```
## Step 4 - Restore Node (Bulk, kembali ke lokasi asal)
### Endpoint
- `PATCH /api/v1/file-manager/restore`
### Contoh request
```json
{
"data": [{ "uuid": "folder-uuid" }, { "uuid": "file-uuid" }]
}
```
Aturan:
- restore tidak menerima `destination_folder_uuid` lagi
- node akan kembali ke lokasi asal (parent/folder saat sebelum di-trash)
- jika lokasi asal root, field `location` tidak dimunculkan
### Contoh response
```json
{
"data": [
{
"index": 0,
"success": true,
"resource": {
"type": "file_manager_restore_result",
"id": "folder-uuid",
"attributes": {
"node_type": "folder",
"status": "ready"
}
}
},
{
"index": 1,
"success": true,
"resource": {
"type": "file_manager_restore_result",
"id": "file-uuid",
"attributes": {
"node_type": "file",
"status": "ready",
"location": {
"folder_id": "folder-uuid-optional"
}
}
}
}
],
"meta": {
"total": 2,
"success": 2,
"failed": 0,
"partial_success": false
}
}
```
## Step 5 - Purge Node (Hard Delete)
### Endpoint
- `DELETE /api/v1/file-manager/purge-delete` (bulk)
### Tujuan
- hapus permanen file atau folder (UUID bisa keduanya)
- kalau UUID folder: subtree ikut dihapus permanen
- kalau UUID file: file dihapus permanen
### Contoh request bulk
```json
{
"data": [
{ "uuid": "folder-uuid" },
{ "uuid": "file-uuid" }
]
}
```
### Contoh response
```json
{
"data": [
{
"index": 0,
"success": true,
"resource": {
"type": "file_manager_purge_result",
"id": "folder-uuid",
"attributes": {
"node_type": "folder",
"status": "purged"
}
}
},
{
"index": 1,
"success": true,
"resource": {
"type": "file_manager_purge_result",
"id": "file-uuid",
"attributes": {
"node_type": "file",
"status": "purged"
}
}
}
],
"meta": {
"total": 2,
"success": 2,
"failed": 0,
"partial_success": false
}
}
```