Problem with two private disks filesystem
Hi, I'm trying to use two private disks (one for uploading attachments to the storage/app/attachments folder and the other for uploading avatar users in storage/app/avatars folder).
This is my config:
'disks' => [
'attachments' => [
'driver' => 'local',
'root' => storage_path('app/attachments'),
'visibility' => 'private'
],
'avatars' => [
'driver' => 'local',
'root' => storage_path('app/avatars'),
//'url' => env('APP_URL').'/storage',
'visibility' => 'private'
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
];
When I use the avatars disk like this:
$path = Storage::disk('avatars')->getDriver()->getAdapter()->getPathPrefix();
$file->move(
$path, $filename
);
the file is uploaded correctly (inside avatars folder), but when I need to get the URL something is going wrong because I get this type of url: '/storage/avatar_1.png' when I use this:
$avatarUrl = Storage::disk('avatars')->url($avatarObject[0]->filename);
the avatar can't not found. If I copy the image to the attachments folder then the avatar is shown in the view correctly.
I'm afraid I'm not understanding how this (the filesystem) goes, I guess I need to get the correct URL or configure it inside filesystems.php so any comment or help will be welcome...
Please or to participate in this conversation.