import boto3 from botocore.client import Config from botocore.exceptions import ClientError MINIO_ENDPOINT = "minioapi.rshtech.com.py" MINIO_ACCESS_KEY = "6uEIJyKR2Fi4UXiSgIeG" MINIO_SECRET_KEY = "8k0kYuvxD9ePuvjdxvDk8WkGhhlaaee8BxU1mqRW" MINIO_IMAGE_BUCKET = "images" MINIO_PDF_BUCKET = "pdfs" MINIO_SECURE = True # HTTPS MINIO_PORT = 443 def main(): try: endpoint_url = f"https://{MINIO_ENDPOINT}:{MINIO_PORT}" if MINIO_SECURE \ else f"http://{MINIO_ENDPOINT}:{MINIO_PORT}" # Crear cliente S3 compatible para MinIO s3 = boto3.client( "s3", endpoint_url=endpoint_url, aws_access_key_id=MINIO_ACCESS_KEY, aws_secret_access_key=MINIO_SECRET_KEY, config=Config(signature_version="s3v4"), region_name="us-east-1" ) print("🔍 Probando conexión…") # Listar buckets response = s3.list_buckets() print("✅ Conexión exitosa. Buckets disponibles:") for bucket in response.get("Buckets", []): print(f" - {bucket['Name']}") # Verificar acceso a buckets específicos for bucket_name in [MINIO_IMAGE_BUCKET, MINIO_PDF_BUCKET]: try: s3.head_bucket(Bucket=bucket_name) print(f"✔ Acceso OK al bucket: {bucket_name}") except ClientError: print(f"❌ No se pudo acceder al bucket: {bucket_name}") print("🎉 Test finalizado correctamente.") except Exception as e: print("❌ Error:", e) if __name__ == "__main__": main()