filament change file upload preview using URL?

hi , i use FileUpload component to save a private file inside app/private/folderName/fileName i have a serveFile route to serve my private files for authenticated users only the FileUpload not showing anything in edit form. i use fillForm to fill form data. Action::make('edit') ->modalHeading('edit') ->form($this->getFormFields()) ->fillForm(fn(User $record): array => [ 'name' => $record->name, 'phone' => $record->phone, 'image' => $record->image, ]) ->action(fn(array $data, User $record) => $this->editUser($record, $data)), private function getFormFields() { return [ Grid::make() ->schema([ FileUpload::make('image') ->label('تصویر پروفایل') ->image() ->directory('users_images') ->visibility('private') ->imageEditor() ->circleCropper() ->storeFiles(false) ->imageResizeTargetWidth(512) ->imageResizeTargetHeight(512) ->imageResizeMode('cover') ->imageCropAspectRatio('1:1') ->imagePreviewHeight('100') ->columnSpanFull(), ]) ]; } how can i fix this ?
2 Replies
Mohamed Ayaou
Mohamed Ayaou4w ago
What is your issue exactly? is it the changing the stored file path? or serving it via a custom roue? or customizing the FileUpload component URL (you may just use the ->default(...) method)? or it is that nothing is being shown in the fileupdload comp in the view page?
toeknee
toeknee4w ago
I think because he is using private he won't be getting the images rendeirng. You need to use a temporary url helper for private urls.

Did you find this page helpful?