Store the full file upload URL not just the filesystem extension
I am trying to use the file upload field to store an image url to a model
image
column. I want the full asset url to be stored to the database, not just the extension of the filesytem path. The file is being uploaded fine but when saving to the database only the extension is being saved, not full path. Am I missing something or do I need to hydrate the column everytime?6 Replies
For example the form is storing
sEyBoG7HX4s5iqW2W4EXofWTx35cko-metaU2NyZWVuc2hvdCAyMDIzLTA4LTExIGF0IDE0LjU5LjE5LnBuZw==-.png
But I want the full url stored eg: https://{aws_url}sEyBoG7HX4s5iqW2W4EXofWTx35cko-metaU2NyZWVuc2hvdCAyMDIzLTA4LTExIGF0IDE0LjU5LjE5LnBuZw==-.png
I can get the full url stored like this, but it seems super hacky
I think there is a
->storeFilenameUsing()
method or similar on the FileUpload?As far as I can tell that's specific to the filename customization and not storing full path rather than just filename @Dennis Koch
unless that's not documented π€
Q why are you storing the full url? The reason the filename is stored is because you are using a disk so that disk should relate the to path that is being stored i.e. filename.
Ah right. I remember someone having the same issue.
I think your approach is valid then.
@toeknee_iom Storing the full path URL so that the asset can be accessed in various places without having to remember which filesystem it was uploaded to?
Ie: the record column includes the asset url instead of an abstracted filename of a specific filesystem. Not sure if i'm explaining myself well π
Thanks @Dennis Koch it does solve my problem π