How to use a file from other project

I wonder if there's a way to get an image from other project. Basically I have a project that guests and users will be using, and another where the admins will be using and I need to get files that the users upload on a project to the other where the admins will be able to see it
6 Replies
hosmar27
hosmar27OP2w ago
I tried this:
MediaAction::make(__('Visualize document'))
->translateLabel()
->icon('heroicon-o-clipboard-document-check')
->modalHeading(__('Curriculum'))
->media(fn ($record) => '../../../../../../../../candidate-system/public/storage/'.$record->attachments->url)
->hidden(function ($record) {
if (empty($record->attachments->url)) {
return true;
} else {
return false;
}
}),
MediaAction::make(__('Visualize document'))
->translateLabel()
->icon('heroicon-o-clipboard-document-check')
->modalHeading(__('Curriculum'))
->media(fn ($record) => '../../../../../../../../candidate-system/public/storage/'.$record->attachments->url)
->hidden(function ($record) {
if (empty($record->attachments->url)) {
return true;
} else {
return false;
}
}),
I'm using this plugin by the way https://filamentphp.com/plugins/hugomyb-media-action#preload But it would be really usefull if anyone could explain to me even using FileUpload, I just want to know how to get to the file outside the project
biebthesecond
biebthesecond2w ago
The best is to probably set up an API endpoint in your other project you can call. Also unrelated, but quick tip to tidy your code up
if (empty($record->attachments->url)) {
return true;
} else {
return false;
}
if (empty($record->attachments->url)) {
return true;
} else {
return false;
}
Can be simplified to:
return empty($record->attachments->url)
return empty($record->attachments->url)
and if you want to use an inline callback you can also do:
fn($record): bool => empty($record->attachments->url)
fn($record): bool => empty($record->attachments->url)
hosmar27
hosmar27OP2w ago
I was thinking that it would end on this hahahah Thanks for the tip 👍
biebthesecond
biebthesecond2w ago
It's a bit of work sadly, but it's definitely the least hacky and securest way to go about it
hosmar27
hosmar27OP2w ago
I’ll try to store everything on a s3 from Amazon, I think it’ll be the best for my projects
biebthesecond
biebthesecond2w ago
That ofcourse also works, setting up a separate accessible file storage 👍

Did you find this page helpful?