<?php
if (session_status() === PHP_SESSION_NONE) {
    session_start();
}

require_once __DIR__ . '/vendor/autoload.php';

use Aws\S3\S3Client;

// ✅ Connexion PDO
try {
    $pdo = new PDO(
        'mysql:host=mysql;dbname=forum_database;charset=utf8mb4',
        'myuser',
        'mypassword',
        [
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
        ]
    );
} catch (PDOException $e) {
    die("Erreur de connexion MySQL : " . $e->getMessage());
}

// ✅ Client MinIO
$s3Client = new S3Client([
    'version' => 'latest',
    'region' => 'us-east-1',
    'endpoint' => 'http://minio:9000',
    'use_path_style_endpoint' => true,
    'credentials' => [
        'key' => 'minioadmin',
        'secret' => 'minioadmin'
    ]
]);

$bucketName = 'bucketforum';
