#!/bin/bash # Script to test file upload to production Firebase Functions # This uses the cloud version, not local PROJECT_ID="cim-summarizer" REGION="us-central1" FUNCTION_NAME="api" # Try to get the function URL echo "🔍 Finding production API endpoint..." # For v2 functions, the URL format is different FUNCTION_URL="https://${REGION}-${PROJECT_ID}.cloudfunctions.net/${FUNCTION_NAME}" echo "Using function URL: ${FUNCTION_URL}" # Test health endpoint first echo "" echo "📡 Testing health endpoint..." HEALTH_RESPONSE=$(curl -s -w "\n%{http_code}" "${FUNCTION_URL}/health") HTTP_CODE=$(echo "$HEALTH_RESPONSE" | tail -n1) BODY=$(echo "$HEALTH_RESPONSE" | head -n-1) if [ "$HTTP_CODE" = "200" ]; then echo "✅ Health check passed" echo "Response: $BODY" else echo "❌ Health check failed with code: $HTTP_CODE" echo "Response: $BODY" exit 1 fi echo "" echo "📤 To upload a file, you need:" echo "1. A valid Firebase authentication token" echo "2. The file to upload" echo "" echo "Run this script with:" echo " ./test-upload-production.sh " echo "" echo "Or test the upload URL endpoint manually with:" echo " curl -X POST ${FUNCTION_URL}/documents/upload-url \\" echo " -H 'Authorization: Bearer YOUR_TOKEN' \\" echo " -H 'Content-Type: application/json' \\" echo " -d '{\"fileName\":\"test.pdf\",\"fileSize\":1000000,\"contentType\":\"application/pdf\"}'"