File size: 1,318 Bytes
11e1578
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
"""Test script to verify storage configuration"""

import os
import sys
sys.path.append('..')

from app.config import settings
from app.storage import get_object_url

def test_config():
    print("=== Storage Configuration Test ===")
    print(f"STORAGE_PROVIDER: {settings.STORAGE_PROVIDER}")
    print(f"S3_ENDPOINT: {settings.S3_ENDPOINT}")
    print(f"S3_BUCKET: {settings.S3_BUCKET}")
    print(f"S3_PUBLIC_URL_BASE: {settings.S3_PUBLIC_URL_BASE}")
    
    if settings.STORAGE_PROVIDER == "s3":
        print("\n=== S3 Storage Test ===")
        try:
            # Test URL generation
            test_key = "maps/test_image.jpg"
            url = get_object_url(test_key)
            print(f"Generated URL for '{test_key}': {url}")
            
            if settings.S3_PUBLIC_URL_BASE:
                print(f"βœ… Using public URL base: {settings.S3_PUBLIC_URL_BASE}")
            else:
                print("⚠️  No S3_PUBLIC_URL_BASE set - will use presigned URLs")
                
        except Exception as e:
            print(f"❌ Error testing S3 storage: {e}")
    else:
        print(f"\n=== Local Storage Test ===")
        print(f"Storage directory: {settings.STORAGE_DIR}")
        print("βœ… Local storage configured")

if __name__ == "__main__":
    test_config()