1051e83da3
This commit introduces a new API endpoint `/api/upload` for handling audio file uploads. It supports multipart form data, extracts `case_id`, `recorded_at`, and `audio` fields. The audio data is saved to a filesystem path determined by the user and case ID, within either the `open/` or `done/` directories. New features include: - Integration with `axum`'s `Multipart` extractor for parsing form data. - Validation of `case_id` as a UUID. - Creation of case directories if they do not exist. - Handling of late uploads to already closed cases by placing files in the `done/` directory and removing any `.remove` marker. - Logging of received recordings. - Definition of `AckResponse` and `AckStatus` models for API responses. - Addition of comprehensive unit tests for various upload scenarios, including new case creation, invalid inputs, authentication, and late uploads.
16 lines
256 B
Rust
16 lines
256 B
Rust
use serde::Serialize;
|
|
|
|
#[derive(Serialize)]
|
|
pub struct AckResponse {
|
|
pub case_id: String,
|
|
pub recorded_at: String,
|
|
pub status: AckStatus,
|
|
}
|
|
|
|
#[derive(Serialize)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum AckStatus {
|
|
Received,
|
|
Gone,
|
|
}
|