Intercepting File Uploads in Livewire

I use Amazon’s Textract and Rekognition services to process uploaded JPG and PNG files on my app. They don’t support HEIC but my users don’t know that so I want to intercept the upload and check and convert as needed before resuming the Livewire execution.

Not sure how to best go about with this in Livewire. Do you guys have any suggestions or leads that I can pursue? Thanks!

Edit:

@this.upload('photo', file, (uploadedFilename) => {
    // Success callback.
}, () => {

Should I use this approach instead? Hook into Javascript and ask another method to inspect the uploaded file? Seems like a dirty approach.

You might look into the updated lifecycle for your photo variable.

public function updatedPhoto() // runs each time $photo is updated
{
    foreach ($this->photo as $photo) {
        // check each $photo to make sure it's not HEIC, if so convert and such.
    }
}

Thanks! I ended up using the updated($name, $value) method and did a switch($name). This would be a cleaner alternative.