F
Filamentβ€’7mo ago
Mike

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
Dennis Koch
Dennis Kochβ€’7mo ago
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
Never used S3, but can't the Filesystem generate the full url based on your settings and file name?!
Mike
MikeOPβ€’7mo ago
@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
Dennis Koch
Dennis Kochβ€’7mo ago
We don't store full urls for files, because it allows to switch the disk/folder without rewriting everything in the DB.
Mike
MikeOPβ€’7mo ago
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
Dennis Koch
Dennis Kochβ€’7mo ago
So the previews for the FileUpload are not working? Any console errors? CORS setup correctly?
Mike
MikeOPβ€’7mo ago
@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
Mike
MikeOPβ€’7mo ago
This is the table builder, image has this code: Tables\Columns\ImageColumn::make('meta_image') ->disk('s3'),
No description
Mike
MikeOPβ€’7mo ago
This is the edit form for the first post
No description
Mike
MikeOPβ€’7mo ago
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(),
Dennis Koch
Dennis Kochβ€’7mo ago
No output in the console? What does the request in the network tab look like?
Mike
MikeOPβ€’7mo ago
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?
Dennis Koch
Dennis Kochβ€’7mo ago
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.
Mike
MikeOPβ€’7mo ago
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
Want results from more Discord servers?
Add your server