I have an issue with FileUpload Component with this issue :
Unable to retrieve the mime_type for file at location: livewire-tmp/3gV8mEXfLVdtzdvzKRuiGxHRe2Kjoj-metaSWNvbmUtQkxDLnBuZw%3D%3D-.png.
[previous exception] [object] (GuzzleHttpExceptionConnectException(code: 0): cURL error 7: Failed to connect to minio.cdm.local port 80 after 0 ms: Couldn’t connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://minio.cdm.local/public/livewire-tmp/3gV8mEXfLVdtzdvzKRuiGxHRe2Kjoj-metaSWNvbmUtQkxDLnBuZw%3D%3D-.png at /app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:275)
That’s make me crazy because I’ve already test all configs.
this is my docker-compose with Traefik :
traefik:
image: "traefik:v3.0"
container_name: "traefik"
command:
# - "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entryPoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
networks:
- internal-network
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
cdm-app:
depends_on:
- traefik
- mysql
- minio
build:
context: ../../
dockerfile: docker/local/images/cdm-app/Dockerfile
volumes:
- ../../src/cdm-app:/app
- ./conf/php-fpm/docker.conf:/usr/local/etc/php-fpm.d/docker.conf
- ./conf/php-fpm/docker-fpm.ini:/usr/local/etc/php/conf.d/docker-fpm.ini
networks:
- internal-network
nginx-cdm-app:
image: nginx:latest
volumes:
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf
- ../../src/cdm-app:/app
depends_on:
- cdm-app
- mysql
- traefik
networks:
- internal-network
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx-cdm-app.rule=Host(`cdm.local`)"
- "traefik.http.routers.nginx-cdm-app.entrypoints=web" cdm-app:
depends_on:
- traefik
- mysql
- minio
build:
context: ../../
dockerfile: docker/local/images/cdm-app/Dockerfile
volumes:
- ../../src/cdm-app:/app
- ./conf/php-fpm/docker.conf:/usr/local/etc/php-fpm.d/docker.conf
- ./conf/php-fpm/docker-fpm.ini:/usr/local/etc/php/conf.d/docker-fpm.ini
networks:
- internal-network
minio:
image: 'minio/minio:RELEASE.2024-08-03T04-33-23Z'
depends_on:
- traefik
ports:
- '9000:9000'
- '9001:9001'
restart: always
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: "password"
MINIO_HTTP_TRACE: /dev/stdout
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 3s
timeout: 10s
retries: 10
volumes:
- '../../data/minio:/data/minio'
command: 'minio server /data/minio --console-address ":9001"'
networks:
- internal-network
labels:
- "traefik.enable=true"
# Console
- "traefik.http.routers.minio-console.rule=Host(`console.cdm.local`)"
- "traefik.http.routers.minio-console.entrypoints=web"
- "traefik.http.routers.minio-console.service=minio-console"
- "traefik.http.services.minio-console.loadbalancer.server.port=9001"
# APi
- "traefik.http.routers.minio.rule=Host(`minio.cdm.local`)"
- "traefik.http.routers.minio.entrypoints=web"
- "traefik.http.routers.minio.service=minio"
- "traefik.http.services.minio.loadbalancer.server.port=9000"
I have already set my /etc/hosts to have DNS to localhost
here my config .env for Laravel :
APP_URL=http://cdm.local
AWS_ACCESS_KEY_ID=xxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxxxx
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=public
AWS_USE_PATH_STYLE_ENDPOINT=true
AWS_ENDPOINT=http://minio.cdm.local
AWS_URL=http://minio.cdm.local/public
MINIO_ENDPOINT=http://minio.cdm.local
I tried this test code :
Route::get('/test', function () {
$fileName = 'test_file.png';
$filePath = sys_get_temp_dir() . '/' . $fileName;
file_put_contents($filePath, 'Test file content');
if (file_exists($filePath)) {
echo "Fichier temporaire créé avec succès.n";
} else {
echo "Erreur lors de la création du fichier temporaire.n";
return;
}
try {
$result = Storage::disk('s3')->put('test/' . $fileName, file_get_contents($filePath));
echo $result ? "Fichier téléchargé avec succès.n" : "Échec du téléchargement du fichier.n";
$mimeType = Storage::disk('s3')->mimeType('test/' . $fileName);
echo "Type MIME du fichier téléchargé: " . $mimeType . "n";
// Récupérez l'URL du fichier
$url = Storage::disk('s3')->url('test/' . $fileName);
echo "URL du fichier téléchargé: " . $url . "n";
} catch (Exception $e) {
echo "Erreur lors du téléchargement ou de la récupération des informations du fichier: " . $e->getMessage() . "n";
}
});
and get this error :
Fichier temporaire créé avec succès.
Erreur lors du téléchargement ou de la récupération des informations du fichier: Unable to write file at location: test_file.png. Error executing “PutObject” on “http://minio.cdm.local/public/test_file.png”; AWS HTTP error: cURL error 7: Failed to connect to minio.cdm.local port 80 after 0 ms: Couldn’t connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://minio.cdm.local/public/test_file.png
That’s weird because the file wasn’t put in bucket.
Where am I missing something ?
Ju Box is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.