Download button for file's Inside Repeater.
how can we download the any type of file that is coming from s3.
More details:
Here is the model which i am using inside Repeater
i am using Action inside the MessageResource Like that
and i am getting the url but it it's saying file does'not exist and i this this approach is not good? ``` ->actions([ //other codes ->infolist([ RepeatableEntry::make('message.messageFiles') ->schema([ ImageEntry::make('fileurl')->height(80), TextEntry::make('size') ->suffixAction( Action::make('download') ->action(function (MessageFile $record, array $data) { if ($record->fileurl) { $dd = response()->download(storage_path($record->fileurl)); } else { Log::error('File not found: ' . $record->fileurl); Notification::make() ->title('File Not Found') ->danger() ->send();
and i am getting the url but it it's saying file does'not exist and i this this approach is not good? ``` ->actions([ //other codes ->infolist([ RepeatableEntry::make('message.messageFiles') ->schema([ ImageEntry::make('fileurl')->height(80), TextEntry::make('size') ->suffixAction( Action::make('download') ->action(function (MessageFile $record, array $data) { if ($record->fileurl) { $dd = response()->download(storage_path($record->fileurl)); } else { Log::error('File not found: ' . $record->fileurl); Notification::make() ->title('File Not Found') ->danger() ->send();
Solution:Jump to solution
I use that exact method perfectly fine.
If you are calling storage_path() then you should only be retuning for example"
messageFiles/myfile.zip...
6 Replies
Are you sure the file exists? if you dd the file path is it 100% right
yes it exists but i think i am getting wrong location there and the modal is above.
@toeknee it think the problem is this i am getting this before my actual url.
i think this should be start from here ?
That’s because you are loading in the storage path with a url… you shouldn’t store the url but the storage path
ok
@toeknee i am getting the exact location and it's exists but i think this it is the problem of my method of dowloading the file ? sir any suggetions to implement download button.
Solution
I use that exact method perfectly fine.
If you are calling storage_path() then you should only be retuning for example"
messageFiles/myfile.zip
as storage path builds:
/home/devisop/htdocs/filamentproject/storage/
ok.