Accept WAV, OGG, FLAC, M4A, and related uploads, and read metadata from non-ID3 tag formats.
63 lines
1.3 KiB
PHP
63 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rules\File;
|
|
|
|
class StoreRecordingRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Popular audio extensions Whisper-compatible providers typically accept.
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
public const AUDIO_EXTENSIONS = [
|
|
'mp3',
|
|
'mpeg',
|
|
'mpga',
|
|
'wav',
|
|
'ogg',
|
|
'oga',
|
|
'flac',
|
|
'm4a',
|
|
'mp4',
|
|
'aac',
|
|
'webm',
|
|
'wma',
|
|
'aiff',
|
|
'aif',
|
|
];
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'audio' => [
|
|
'required',
|
|
File::types(self::AUDIO_EXTENSIONS)->max(102400),
|
|
],
|
|
'title' => ['nullable', 'string', 'max:255'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'audio.required' => 'Please choose an audio file to upload.',
|
|
'audio' => 'Unsupported audio type. Use MP3, WAV, OGG, FLAC, M4A, AAC, WebM, WMA, or AIFF.',
|
|
'audio.max' => 'The audio file may not be larger than 100 MB.',
|
|
];
|
|
}
|
|
}
|