File upload on s3 with Minio (sail)
Hi,
I've alredy read the other posts about this topic but i can't get it working.
The scenario:
A category resource where i want to upload a picture that should be public (think about a sort of eccomerce).
In the resource (form) i have
in .env:
Using something like
Storage::disk('s3')->put('categories/asd.txt','asd');
works like a charm, but when i do it from web interface it gives me an error.
What seems strange is that filament tries to upload directly the picture to minio:
livewire.js?id=11c49d7e:3953 PUT http://minio:9000/mybucketname/livewire-tmp/jiuIgVyZYQO9hFAyFvZT9bvf5q3zrx-metaYjMuanBn-.jpg?x-amz-acl=private&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=4VfWaDjtRdnIjFh1osj9%2F20230830%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230830T081610Z&X-Amz-SignedHeaders=host%3Bx-amz-acl&X-Amz-Expires=300&X-Amz-Signature=0bac68f62bcceb8eeeab1ca27fe157095c927aa2df4924f8bb8f3e104f7f5c3a net::ERR_NAME_NOT_RESOLVED
am i missing something?
thanks4 Replies
I think this error happens because the host machine does not know how to resolve "http://minio:9000". However, Laravel container knows, that's why it works inside the application, but not in the browser when Filepond makes the request. I'm trying to find a solution for that
So, I managed to find a solution. I don't know if this is the best one, but it's working for now.
In my
docker-compose
file I added the following:
MinIO always get the same IP address now.
We can add now change AWS_ENDPOINT=http://minio:9000
to AWS_ENDPOINT=http://172.20.0.5:9000
, and everything is going to work. The file will be uploaded in the browser, and the path will be properly saved in the database.I tried your solution, but it did not resolve.
@giagara not sure if you've figured out how to do it... but is so damn simple took me 30 minutes after trying the docker-compose solution proposed by @mtbossa
I just added
127.0.0.1 minio
to my hosts file
No other changes are required, because the browser will try to access minio:9000 same as the laravel container so you just have to tell it that minio on the host is localhost
Docker network will solve the rest for minio:9000 with it's internal network IPs and all that stuffYes, this is definitely a solution. I don't like this approach of having to mess with hosts file... But I think that there aren't many solution for this, at least for now