Upload image/video to server right after it's been added as temp file

Hello everyone, I'm trying to find the right event to hook into that would help me to store the image right after it's been validated. I'm looking for something like afterValidation() I guess. I have the following component
SpatieMediaLibraryFileUpload::make('file')
->label('Media')
->previewable()
->acceptedFileTypes([
'image/jpeg',
'image/png',
'image/webp',
'video/mp4',
'video/webm',
'video/x-ms-wmv',
'video/quicktime'
])
->maxSize(1024 * 1024)
->disk(fn() => app()->environment('production') ? 's3' : 'public')
->imageEditor()
->image()
->directory(Filament::getTenant()->slug . DIRECTORY_SEPARATOR . 'media')
->moveFiles()
->afterStateHydrated(function (TemporaryUploadedFile $file) {
$originalName = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$size = $file->getSize();
$mimeType = $file->getMimeType();

// Perform custom logic here (e.g., logging or additional processing)
\Log::info('Uploaded File Metadata:', [
'name' => $originalName,
'extension' => $extension,
'size' => $size,
'mime_type' => $mimeType,
]);
})
->required()
SpatieMediaLibraryFileUpload::make('file')
->label('Media')
->previewable()
->acceptedFileTypes([
'image/jpeg',
'image/png',
'image/webp',
'video/mp4',
'video/webm',
'video/x-ms-wmv',
'video/quicktime'
])
->maxSize(1024 * 1024)
->disk(fn() => app()->environment('production') ? 's3' : 'public')
->imageEditor()
->image()
->directory(Filament::getTenant()->slug . DIRECTORY_SEPARATOR . 'media')
->moveFiles()
->afterStateHydrated(function (TemporaryUploadedFile $file) {
$originalName = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$size = $file->getSize();
$mimeType = $file->getMimeType();

// Perform custom logic here (e.g., logging or additional processing)
\Log::info('Uploaded File Metadata:', [
'name' => $originalName,
'extension' => $extension,
'size' => $size,
'mime_type' => $mimeType,
]);
})
->required()
What would the best event to replace afterStateHydrated() here?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server