My app uses Laravel as backend, and React as a frontend solution with Inertia as intermediary.
The idea is to load .wav files from media storage (say /storage/app/audio) to let users playback phone calls. File names should be passed to the <audio> tag inside the CallPreview component for it to grab the actual files from the storage folder.
const CallPreview: React.FC<{
date: string;
grade: string;
recording_name: string;
}> = ({
date,
grade,
recording_name
}) => {
return (
<div className="call-preview">
<div className="call-preview-date">{date}</div>
<div className="call-preview-grade">Grade: {grade}</div>
<div className="call-preview-record">
<audio controls src={recording_name}></audio>
</div>
</div>
);
}
It turns out, you cannot access any of the asset files directly, if I understood it correctly. You have to use something akin to Storage::*path to file* in routes, which would have defeated the purpose since the files should be loaded dynamically based on user's input.
Is there a better way? Am I missing something?