F
Filament12mo ago
msalehi

MediaLibrary not working with minIO with docker

Hi there, i've installed minIO in a docker container and i'm using Spatie Media Library plugin for uploading my images to minIO when the filesystem disk set to public or local it has not any problem and everything works fine! but when i choose minio for disk, only the temp-livewire files are uploading successfully to minIO but the original files not uploading and does not save any database record for media table. here is my code :
SpatieMediaLibraryFileUpload::make('images')
->label('تصاویر')
->multiple()
->required()
->collection('images')
->visibility('public')
->reorderable()
->imageEditor()
->columnSpan(2),
SpatieMediaLibraryFileUpload::make('images')
->label('تصاویر')
->multiple()
->required()
->collection('images')
->visibility('public')
->reorderable()
->imageEditor()
->columnSpan(2),
and here is my .env settings:
FILESYSTEM_DISK=minio
FILAMENT_FILESYSTEM_DISK=minio
MEDIA_DISK=minio
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=admin_password
MINIO_ENDPOINT=http://127.0.0.1:9000
MINIO_REGION=us-west-2
MINIO_BUCKET=test
FILESYSTEM_DISK=minio
FILAMENT_FILESYSTEM_DISK=minio
MEDIA_DISK=minio
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=admin_password
MINIO_ENDPOINT=http://127.0.0.1:9000
MINIO_REGION=us-west-2
MINIO_BUCKET=test
is there any bug or have I made a mistake somewhere?
11 Replies
LeandroFerreira
LeandroFerreira12mo ago
try this
FILESYSTEM_DRIVER=s3
AWS_ACCESS_KEY_ID=admin
AWS_SECRET_ACCESS_KEY=admin_password
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=test
AWS_ENDPOINT=http://minio:9000
AWS_URL=http://127.0.0.1:9000/test
AWS_USE_PATH_STYLE_ENDPOINT=true
FILESYSTEM_DRIVER=s3
AWS_ACCESS_KEY_ID=admin
AWS_SECRET_ACCESS_KEY=admin_password
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=test
AWS_ENDPOINT=http://minio:9000
AWS_URL=http://127.0.0.1:9000/test
AWS_USE_PATH_STYLE_ENDPOINT=true
msalehi
msalehiOP12mo ago
Thanks, i tried this but does not worked even for temp file !! it seems that access key and secret access key is deprecated in minIO new version.
LeandroFerreira
LeandroFerreira12mo ago
hum, not sure
msalehi
msalehiOP12mo ago
i saw that in
docker logs minio
docker logs minio
LeandroFerreira
LeandroFerreira12mo ago
I was using it with laravel sail and it was working. I'm using Mac now. I installed minio and it is working as well
msalehi
msalehiOP12mo ago
i'm using laravel with my own docker configurations. i'm going to inspect sail configurations to know about minio configs. this is a little bit weird. i'm using WSL2 on Windows.
LeandroFerreira
LeandroFerreira12mo ago
maybe you can try it using sail Create a bucket called local and try this
FILESYSTEM_DRIVER=s3
AWS_ACCESS_KEY_ID=sail
AWS_SECRET_ACCESS_KEY=password
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=local
AWS_ENDPOINT=http://minio:9000
AWS_URL=http://localhost:9000/local
AWS_USE_PATH_STYLE_ENDPOINT=true
FILESYSTEM_DRIVER=s3
AWS_ACCESS_KEY_ID=sail
AWS_SECRET_ACCESS_KEY=password
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=local
AWS_ENDPOINT=http://minio:9000
AWS_URL=http://localhost:9000/local
AWS_USE_PATH_STYLE_ENDPOINT=true
msalehi
msalehiOP12mo ago
i used my own env variable and now i'm sure that my project is connected to minio, because i tested it using tinker and Storage facade and it worked, but i found that the uploaded file field, before saving data is set to an empty array
protected function mutateFormDataBeforeSave(array $data): array
{
dd($data);
}
protected function mutateFormDataBeforeSave(array $data): array
{
dd($data);
}
and returned something like this :
array:24 [
...
...
"toilets_count" => 2
"parking_count" => 4
"images" => []
]
array:24 [
...
...
"toilets_count" => 2
"parking_count" => 4
"images" => []
]
as you can see images is empty! i tested this using default fileUpload component . i'm still have the problem, i think there is a bug in FileUpload component, and seems that TemporaryFileUploader class does not compatible with minio
ROOT-LEE
ROOT-LEE11mo ago
It's working. This is my snippet of code. Ressource:
SpatieMediaLibraryFileUpload::make('pdf')
->acceptedFileTypes(['application/pdf'])
->collection('pdf')
->disk('s3')
->downloadable()->previewable()->imageEditor()->visibility('private')
,
SpatieMediaLibraryFileUpload::make('pdf')
->acceptedFileTypes(['application/pdf'])
->collection('pdf')
->disk('s3')
->downloadable()->previewable()->imageEditor()->visibility('private')
,
Config/FileSystem
'default' => env('FILESYSTEM_DISK', 'local'),
//....

Filesystem
'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,

],
'default' => env('FILESYSTEM_DISK', 'local'),
//....

Filesystem
'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,

],
and the .env file:
AWS_ACCESS_KEY_ID=xxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxx
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=test
AWS_USE_PATH_STYLE_ENDPOINT=true
AWS_URL=https://server_url/test
AWS_ENDPOINT=https://server_url
MEDIA_DISK=s3
AWS_ACCESS_KEY_ID=xxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxx
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=test
AWS_USE_PATH_STYLE_ENDPOINT=true
AWS_URL=https://server_url/test
AWS_ENDPOINT=https://server_url
MEDIA_DISK=s3
Luiz
Luiz10mo ago
I'm having the same problem. I even tried changing the access policy to public on the bucket and nothing, dead. There is no error, there is nothing So after hours and hours trying to find a solution a finally stumbled on something and I thinks is a good solution. For anyone using minio with docker I changed AWS_ENDPOINT to http://host.docker.internal:9000 and them it started working flawless I forgot where I read the solution. So I apologize to the author of this solution
developer
developer5mo ago
I copied this repo and it's working like a charm! https://github.com/nicolus/laravel-minio-example
Want results from more Discord servers?
Add your server