S3 image upload not getting full url?
I have a fileupload field called featured_image. Im uploading the files to s3 disk, all good with that however the content saved to the database is just the file name saved into s3 and not the full url, so in this case previews dont work etc. I also have tiptap plugin installed which works all good.
What am i missing? Thank you
FileUpload::make('meta_image')
->label('Featured image')
->image()
->disk('s3')
->directory('images/posts')
->visibility('public')
->maxSize(2048)
->required(),
My s3 filesystem config:
's3' => [
'driver' => 's3',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'bucket' => env('AWS_BUCKET'),
'url' => env('AWS_URL'),
'endpoint' => env('AWS_ENDPOINT'),
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
13 Replies
however the content saved to the database is just the file name saved into s3 and not the full url, so in this case previews dont work etcNever used S3, but can't the Filesystem generate the full url based on your settings and file name?!
@Dennis Koch i mean i can do it manually using states but i wonder if im doing something wrong as it makes no sense to me
We don't store full urls for files, because it allows to switch the disk/folder without rewriting everything in the DB.
Got it, thank you
@Dennis Koch Sorry, following on this again. The thing is, isnt it supposed to append to the AWS_URL or AWS_ENDPOINT? Because this seems very counter productive. While storing the filename on db seems fine as a logical approach, im still specifying that the disk is s3, which in that case should preview the uploaded image using the s3 url declared in the env file. Correct me if wrong, as i see zero info on the net on the issue
So the previews for the FileUpload are not working? Any console errors? CORS setup correctly?
@Dennis Koch nope not working, on table build if i specify s3 disk for that image it works correctly but the FileUpload form will not behave the same. No cors issues, im locally developing, i think the file uploader fails to use s3 for file previews, and since the image url in the database is just the image name it never finds it. Please see images below
This is the table builder, image has this code:
Tables\Columns\ImageColumn::make('meta_image')
->disk('s3'),
This is the edit form for the first post
which the image is uploaded in s3, with the following code:
FileUpload::make('meta_image')
->label('Featured image')
->image()
->disk('s3')
->directory('images/posts')
->visibility('public')
->maxSize(2048)
->required(),
No output in the console? What does the request in the network tab look like?
as i said, i can probabily make this work, but this seem like an issue within filament, unless i messed some configs
omg sorry, it is a cors issue, it was hidden in the errors section in the console. hehe. so i suppose this need to be whitelisted from s3?
it was hidden in the errors section in the console.Why on earth do you hide the errors from console? π π Yes. You need to properly configure the allowlist for your bucket.
i had it in the 'user messages' section, so my brain through exiting and reloading would go default state in the console. What a noob move lol, thank you