Mona
Mona
FFilament
Created by marksman on 8/15/2024 in #❓┊help
change fileupload field preview url
I found this for filepond plugin media preview but also not working https://github.com/nielsboogaard/filepond-plugin-media-preview can you suggest me any other solution? or just make an option when edit the record to upload a new video or just keep the old one without previewing the video? Many thanks for you help 🙂
14 replies
FFilament
Created by marksman on 8/15/2024 in #❓┊help
change fileupload field preview url
you mean it is better to use ->disk('s3') and in this case we can save it directly once we click save? but still with this way I can't see the preview on the FileUpload when edit the record 😦
14 replies
FFilament
Created by marksman on 8/15/2024 in #❓┊help
change fileupload field preview url
@toeknee hello I am trying to use S3 to upload videos to it and I save the full path in the database as the access is public.. what I did is first save the files in the local storage then when click save I upload the files to S3 and delete them from the local storage.. this is working fine I think The issue I face is to show the video on the FileUpload filament when I edit the record.. could you please help me find a solution for preview the video Here is my code, in the filament resource: FileUpload::make('link_en') ->disk('public') ->directory('spotlights/videos') ->label('Video (English)') ->acceptedFileTypes(['video/*']) ->preserveFilenames() ->required(), and in the Model I do the upload: static::saving(function ($model) { if (!empty($model->link_en)) { $originalFilePath = $model->link_en; $tempFilePath = storage_path('app/public/' . $model->link_en); $s3FilePath = 'spotlights/videos/' . $model->slug . basename($tempFilePath); // Upload to S3 if (Storage::disk('s3')->put($s3FilePath, file_get_contents($tempFilePath))) { Storage::disk('s3')->setVisibility($s3FilePath, 'public'); $s3Bucket = config('filesystems.disks.s3.bucket'); $s3Region = config('filesystems.disks.s3.region'); $s3BaseUrl = "https://{$s3Bucket}.s3.{$s3Region}.amazonaws.com/"; $fullPath = $s3BaseUrl . $s3FilePath; $model->link_en = $fullPath; Storage::disk('public')->delete($originalFilePath); } } }
14 replies