F
Filament15mo ago
MRBUG

avatar from s3

How to get this avatar from s3?
This code is from the documentation.
https://filamentphp.com/docs/3.x/panels/users#setting-up-user-avatars
<?php

namespace App\Models;

use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements FilamentUser, HasAvatar
{
// ...

public function getFilamentAvatarUrl(): ?string
{
return $this->avatar_url;
}
}
<?php

namespace App\Models;

use Filament\Models\Contracts\FilamentUser;
use Filament\Models\Contracts\HasAvatar;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements FilamentUser, HasAvatar
{
// ...

public function getFilamentAvatarUrl(): ?string
{
return $this->avatar_url;
}
}
6 Replies
Vp
Vp15mo ago
Store s3 avatar link in avatar_url column of your users table in DB
MRBUG
MRBUGOP15mo ago
yes i am storing but i want to get with location like https://ddkjk.vi/s3/sdakjsadkj.png like that so this is in my db sdakjsadkj.png and i want full link https://ddkjk.vi/s3/sdakjsadkj.png like that ???
toeknee
toeknee15mo ago
So you want a custom temporary s3 url driver basically with routing
MRBUG
MRBUGOP15mo ago
i want to show avatar form s3 but i am using this https://filamentphp.com/docs/3.x/panels/users#setting-up-user-avatars it is giving location but not aws url
toeknee
toeknee15mo ago
This isn't making much sense, you should be storing the image in s3 and storing the full s3 path if the url is public If the image isn't public then you can write a getter to get it from the path i.e. Storage::disk('s3')->temporaryUrl($path);
MRBUG
MRBUGOP15mo ago
ok will try this thanks its working thanks .

Did you find this page helpful?