Skip to main content

upload_ir_profile

Function upload_ir_profile 

Source
pub fn upload_ir_profile(
    file_service: State<'_, FileService>,
    file_name: String,
    file_bytes: Vec<u8>,
) -> Result<String, String>
Expand description

Uploads a custom IR WAV file to the user’s custom IR directory.

The upload pipeline:

  1. The frontend reads the user-selected file into a Uint8Array and sends the raw bytes together with the original filename.
  2. This command delegates to FileService::save_custom_ir_profile, which sanitizes the name, validates the WAV data, and writes the file to disk.
  3. On success, the sanitized filename is returned so the frontend can immediately add the new entry to the IR list without re-fetching.

§Errors

Returns Err when the file fails validation (wrong extension, no impulse, duplicate of a default profile) or cannot be written to disk.