1.5 KiB
1.5 KiB
File Manager
Attachment (Step by Step)
A. Tambah Attachment
Endpoint
POST /api/v1/file-manager/attachments/create
FE kirim request ini
{
"data": {
"type": "file_manager_attachment_create",
"attributes": {
"file_id": "file-uuid",
"ref_type": "helicopter",
"ref_id": "business-entity-uuid",
"category": "document",
"sort_order": 0,
"is_primary": false
}
}
}
Keterangan:
file_id,ref_type,ref_idwajibcategoryopsionalsort_orderopsional (default 0)is_primaryopsional (default false)
B. Lihat Attachment by Reference
Endpoint
GET /api/v1/file-manager/attachments/get-all?ref_type=<type>&ref_id=<id>
Contoh
GET /api/v1/file-manager/attachments/get-all?ref_type=helicopter&ref_id=business-entity-uuid
Catatan urutan default:
- jika query
sorttidak dikirim, urutan default adalahsort_order ASC, created_at DESC - artinya untuk
sort_orderyang sama, attachment terbaru tampil lebih dulu
C. Detail Attachment
Endpoint
GET /api/v1/file-manager/attachments/get/:uuid
D. Hapus Attachment (Detach)
Endpoint
DELETE /api/v1/file-manager/attachments/delete/:uuid
Contoh response
{
"data": {
"type": "file_manager_attachment_delete",
"attributes": {
"detached": true
}
}
}
Ringkasan
- create relation file -> entity bisnis
- list by
ref_type + ref_id - get detail relation
- delete relation (detach)