Upload media files to device via REST API
You can now upload media files (tachograph files, video clips, and images) directly to device media storage via the new POST /gw/devices/{dev-selector}/media API method.
Previously, device media storage could only be populated by physical hardware devices uploading files through supported protocols. Now you can register media files from any external source — your own backend, a third-party system, or even manual uploads — and they will be processed through the same pipeline as device-originated files, including device message registration with media links.
How it works
The method accepts a multipart/form-data request with two parts:
file — the actual media file
data — JSON object specifying the file type and optional metadata
Two file types are supported:
Tachograph files (type: "tacho"):
curl -X POST 'https://flespi.io/gw/devices/123456/media' \
-H 'Authorization: FlespiToken YOUR_TOKEN' \
-F 'file=@driver_card.ddd' \
-F 'data={"type":"tacho","meta":{"created":1775000000,"vin":"WDB1234567890","plate_number":"AB123CD","driver_id":"1200000000110200","driver_first_name":"John","driver_last_name":"Smith","region":"LT"}}'
Video/Image files (type: "video"):
curl -X POST 'https://flespi.io/gw/devices/123456/media' \
-H 'Authorization: FlespiToken YOUR_TOKEN' \
-F 'file=@event_clip.mp4' \
-F 'data={"type":"video","meta":{"channel":1,"created":1775000000}}'
Upon upload, flespi will:
- Process the file through the standard media pipeline (including video codec detection, tacho file handling, etc.)
- Store the file in device media storage with a unique UUID and public access link
- Register a device message at the
created timestamp with media=true and corresponding media.tacho / media.video.X / media.image.X parameters
This means all downstream integrations — streams, plugins (including tacho-file-parse), MQTT subscriptions, and webhooks — will process uploaded files exactly as if they came from the device itself.
Extra parameters
You can attach custom data at two levels:
params — extra attributes stored on the media file itself (accessible via GET /gw/devices/{dev-selector}/media)
message_params — extra parameters injected into the generated device message
meta — file-type-specific metadata (timestamps, driver info for tacho, camera channel for video)
Use cases
- Tachograph file import: Upload .ddd files obtained from external sources (card readers, third-party download tools, legacy systems) into flespi device media storage. Files will be automatically processed by the tacho-file-parse plugin if assigned, and forwarded to downstream platforms via streams — including Wialon and S3.
- Video/photo import: Register externally captured video clips or images against a device timeline, making them accessible through the same Mediabox UI and API as device-originated media.
- Data migration: Move historical media files from another platform into flespi while preserving original timestamps and metadata.
- Testing and development: Upload sample media files to test your integration pipeline without requiring a physical device connection.