There is a function written in the library trait, path and function is as below
Path: \vendor\laravel\jetstrem\src\HasProfilePhoto.php
Function:
/**
* Update the user's profile photo.
*
* @param \Illuminate\Http\UploadedFile $photo
* @return void
*/
public function updateProfilePhoto(UploadedFile $photo)
{
tap($this->profile_photo_path, function ($previous) use ($photo) {
$this->forceFill([
'profile_photo_path' => $photo->storePublicly(
'profile-photos', ['disk' => $this->profilePhotoDisk()]
),
])->save();
if ($previous) {
Storage::disk($this->profilePhotoDisk())->delete($previous);
}
});
}
As you can see for uploading the profile image on s3 the function used is storePublicly, but in my case, the s3 policy is not defined as publicly read, so I have overloaded the same function in
app\Actions\Fortify\UpdateUserProfileInformation.php
On top of the class add the Trait as use HasProfilePhoto;
/**
* Update the user's profile photo.
*
* @param \Illuminate\Http\UploadedFile $photo
* @return void
*
*
*/
public function updateProfilePhoto($user, UploadedFile $photo)
{
tap($user->profile_photo_path, function ($previous) use ($photo, $user) {
$user->forceFill([
'profile_photo_path' => $photo->store(
'profile-photos', ['disk' => config('jetstream.profile_photo_disk')]
),
])->save();
if ($previous) {
\Storage::disk(config('jetstream.profile_photo_disk'))->delete($previous);
}
});
}
This works for me, I hope if you face similar issue, then it would help you.