Files
resumeformatter/test_r2_connection.py
Laxmi Khilnani cda50356b4
Some checks failed
Profile Linker Docker Build / Build and push Docker image (push) Failing after 3s
feat: Complete Smart Resume Formatter with R2 and Gemini AI integration
- Integrated Cloudflare R2 for template storage and converted file management
- Added Google Gemini AI for resume parsing and HTML generation
- Created backend API endpoints for templates, conversion, and history
- Refactored frontend to use real API instead of mock data
- Fixed Docker networking issues (IPv6/IPv4) for R2 connectivity
- Added resumeService.ts for frontend API integration
- Updated Vite configuration for proper asset serving in Docker
- Successfully tested with 13 templates from R2 bucket
2025-10-14 21:43:41 +05:30

58 lines
1.8 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Quick test script to verify R2 connection and list templates
Run this to test if R2 credentials are working before Docker build
"""
import os
import sys
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Add backend to path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'backend'))
try:
from app.services.r2_service import r2_service
print("🔍 Testing Cloudflare R2 Connection...\n")
# Test 1: List templates
print("📝 Test 1: Listing templates from R2...")
templates = r2_service.list_templates()
if templates:
print(f"✅ SUCCESS! Found {len(templates)} template(s):")
for template in templates:
print(f" - {template}")
else:
print("⚠️ No templates found (this might be expected if bucket is empty)")
print("\n" + "="*50 + "\n")
# Test 2: List converted resumes
print("📄 Test 2: Listing converted resumes from R2...")
resumes = r2_service.list_converted_resumes(limit=5)
if resumes:
print(f"✅ SUCCESS! Found {len(resumes)} resume(s):")
for resume in resumes[:5]: # Show first 5
print(f" - {resume['name']} ({resume['size']} bytes)")
else:
print("⚠️ No converted resumes found (this might be expected)")
print("\n" + "="*50 + "\n")
print("✅ R2 Connection Test Complete!")
print("\nYou can now run: docker-compose up --build")
except ImportError as e:
print(f"❌ Import Error: {e}")
print("\nThis is expected if you haven't installed backend dependencies yet.")
print("Docker will handle this automatically during build.")
except Exception as e:
print(f"❌ Error: {e}")
print("\nCheck your R2 credentials in .env file")
sys.exit(1)