'latest', 'region' => 'us-east-1', // 对于MinIO,这个参数通常不重要,但SDK可能需要它 'endpoint' => env("ENDPOINT"), // 替换为您的MinIO服务器地址 'use_path_style_endpoint' => true, // 对于MinIO,通常需要将此设置为true 'credentials' => [ 'key' => 'Kr2gB8Lo3nRvm39naO43', 'secret' => '2cPcnAOs3YKiLEMonx62uRN3Ep4u1HYPeSNv1HzG', ], ]; var_dump("配置信息:",$config); // 创建 MinIO 客户端 $minioClient = new S3Client($config); // var_dump("连接:",$minioClient); try { // 获取所有存储桶列表 $result = $minioClient->listBuckets(); var_dump($result); // 提取存储桶名称 $buckets = array_column($result['Buckets'], 'Name'); // 返回响应 return $this->response->json([ 'success' => true, 'buckets' => $buckets, ]); } catch (\Aws\Exception\AwsException $e) { var_dump("错误:",$e->getMessage()); // 处理AWS异常 return $this->response->withStatus(500)->json([ 'success' => false, 'error' => $e->getMessage(), ]); } catch (\Exception $e) { // 处理其他异常 return $this->response->withStatus(500)->json([ 'success' => false, 'error' => 'An unexpected error occurred: ' . $e->getMessage(), ]); } } }