4.1 KiB
4.1 KiB
File Manager Aircraft Image Flow
This document explains the upload + create flow specifically for aircraft images.
Purpose
This flow is used to upload aircraft images (drag-and-drop) and persist file metadata into a forced folder hierarchy based on the aircraft designation.
Main differences compared to the regular file flow:
- dedicated upload endpoint:
POST /api/v1/file-manager/files/upload-aircraft-image - dedicated create endpoint:
POST /api/v1/file-manager/files/create-aircraft-image content_typemust beimage/*- target folder is forced to:
__system_root_files__ > aircraft > <aircraft designation> aircraft_uuidis required in the create request per item
Prerequisites
- User is logged in and has
file_manager.createpermission. - Frontend has per-file data:
name,content_type,size_bytes, and binary file.
Step 1 - Request Upload Intent (Aircraft)
Endpoint:
POST /api/v1/file-manager/files/upload-aircraft-image
Request body (bulk, minimum 1 item):
{
"data": [
{
"type": "file_manager_file_upload_intent",
"attributes": {
"name": "aircraft-front.jpg",
"content_type": "image/jpeg",
"size_bytes": 42170
}
}
]
}
Important validation rules in this endpoint:
datamust be an arraytypemust befile_manager_file_upload_intentnameis requiredcontent_typeis required and must start withimage/size_bytes >= 0
Per-item response (partial success is possible), FE receives:
upload_intent_uuidupload_urlmethod(PUT)required_headers- object info (
bucket,key) expires_at,expires_in_seconds
Step 2 - Upload Binary Directly to Object Storage
For each item with success: true from step 1:
- take
upload_url - perform
PUTbinary file to that URL - send headers according to
required_headers
Example:
await fetch(upload_url, {
method: "PUT",
headers: {
"Content-Type": file.type
},
body: file
});
Notes:
- 1 file = 1
PUTrequest - parallel upload is allowed with a concurrency limit
- files that fail
PUTmust not be sent to the create step
Step 3 - Create File Record (Aircraft)
Endpoint:
POST /api/v1/file-manager/files/create-aircraft-image
Request body:
{
"data": [
{
"type": "file_manager_file_create",
"attributes": {
"upload_intent_uuid": "019d8215-c622-7576-86bd-3ddeecaf4867",
"aircraft_uuid": "019d8215-c799-7209-9237-2e2f5d0f8709",
"name": "aircraft-front.jpg"
}
}
]
}
Important validation rules:
datamust be an arraytypemust befile_manager_file_createorfile_manager_fileupload_intent_uuidis required and must be a valid UUIDaircraft_uuidis required and must be a valid UUIDnameis required
Aircraft-specific behavior:
- backend loads aircraft by
aircraft_uuidand reads itsdesignation - backend resolves/creates folder hierarchy:
__system_root_files__(system root)aircraftunder system root<designation>underaircraft(example:OE-XHZ)
- final file is created inside
<designation>folder folder_idfrom payload is ignored in this endpoint because folder is derived from aircraft designation
Step 4 - Backend Process During Create
For each valid item:
- backend validates and loads aircraft from
aircraft_uuid - backend resolves/creates
__system_root_files__ > aircraft > <designation> - backend validates uploaded object from
upload_intent_uuid - backend creates file node in
<designation>folder - file status enters normal file manager lifecycle (
uploaded -> processing -> validated -> readyor failed)
Status Codes
201: all create items succeed207: partial success (mixed success and failure)404: aircraft not found (per-item in bulk response)422: payload validation error400: invalid JSON payload503: aircraft service unavailable
FE Integration Summary
- call
upload-aircraft-image - upload binary to storage via presigned URL
- call
create-aircraft-imageonly for items with successfulPUT - store resulting file
idfor reference in aircraft module