- Issue created by @dan_metille
- ๐ฐ๐ฌKyrgyzstan dan_metille
Make files save to the fieldโs configured file_directory instead of hard-coded public://
The AI Audio Field module currently ignores the "File Directory" settings configured for audio file fields, instead hardcoding file paths to public:// when generating audio files using AI services. This prevents proper file organization and leads to all generated audio files being saved in the public root directory.
Configure a Media Audio type with a custom directory setting for "field_media_audio_file" (e.g., "audio/[date:custom:Y]-[date:custom:m]")
Use the AI Audio Field module to generate audio content
Observe that generated audio files are stored directly in public:// instead of in the configured subdirectory
Current behavior
AI-generated audio files are always stored directly in the public files directory with a hardcoded filename "test.mp3" regardless of any field configuration.
Expected behavior
AI-generated audio files should respect the "File Directory" configuration of the field_media_audio_file field, including any tokens, just like standard file uploads do.
The issue exists in two files:
Both files contain the same code pattern that hardcodes the file path to public://:
$file = $output->getNormalized()[0]->getAsFileEntity('public://', 'test.mp3');
This code should be updated to retrieve and respect the field's directory configuration.
The attached patch implements a fix for both affected files by:
This fix improves file organization and prevents the public files root directory from becoming cluttered with AI-generated content. It also ensures that directory-based backup and organizational strategies work properly for AI-generated content.
Active
1.0
Code
Make files save to the fieldโs configured file_directory instead of hard-coded public://