Spaces:
Running
Running
Download backend/scripts/check_supabase_bucket.py from axeronis/microfunnel-api: direct link, hf CLI and curl.
- Browser
- Download file 2.56 kB
-
https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/backend/scripts/check_supabase_bucket.py
- Command line
-
hf download hf://spaces/axeronis/microfunnel-api/backend/scripts/check_supabase_bucket.py
-
curl -L -o check_supabase_bucket.py https://huggingface.co/spaces/axeronis/microfunnel-api/resolve/main/backend/scripts/check_supabase_bucket.py
2.56 kB
| """ | |
| Quick script to check if Supabase bucket is configured correctly. | |
| Run: python -m scripts.check_supabase_bucket | |
| """ | |
| import sys | |
| from app.core.supabase import supabase_client | |
| def main(): | |
| print("=" * 60) | |
| print("Supabase Bucket Configuration Check") | |
| print("=" * 60) | |
| if not supabase_client: | |
| print("β Supabase client not initialized!") | |
| print(" Check SUPABASE_URL and SUPABASE_KEY in .env") | |
| return False | |
| print("β Supabase client initialized") | |
| # List buckets | |
| try: | |
| buckets = supabase_client.storage.list_buckets() | |
| bucket_names = [b.name for b in buckets] | |
| print(f"\nπ¦ Available buckets: {bucket_names}") | |
| if "chat-attachments" not in bucket_names: | |
| print("\nβ 'chat-attachments' bucket NOT found!") | |
| print(" Create it in Supabase Dashboard:") | |
| print(" 1. Storage β New bucket") | |
| print(" 2. Name: chat-attachments") | |
| print(" 3. Public: ON") | |
| return False | |
| print("β 'chat-attachments' bucket exists") | |
| except Exception as e: | |
| print(f"β Error listing buckets: {e}") | |
| return False | |
| # Test upload | |
| try: | |
| test_path = "test/check.txt" | |
| test_content = b"Test upload from check script" | |
| print(f"\nβ¬οΈ Testing upload to {test_path}...") | |
| result = supabase_client.storage.from_("chat-attachments").upload( | |
| path=test_path, | |
| file=test_content, | |
| file_options={"content-type": "text/plain", "upsert": "true"} | |
| ) | |
| print(f"β Upload successful!") | |
| # Get public URL | |
| public_url = supabase_client.storage.from_("chat-attachments").get_public_url(test_path) | |
| print(f"β Public URL: {public_url}") | |
| # Cleanup | |
| print(f"\nπ§Ή Cleaning up test file...") | |
| supabase_client.storage.from_("chat-attachments").remove([test_path]) | |
| print("β Cleanup complete") | |
| except Exception as e: | |
| print(f"β Upload failed: {e}") | |
| print("\n Possible issues:") | |
| print(" 1. Bucket is not public") | |
| print(" 2. Missing RLS policy for INSERT") | |
| print(" 3. SUPABASE_KEY doesn't have sufficient permissions") | |
| return False | |
| print("\n" + "=" * 60) | |
| print("β All checks passed! Bucket is configured correctly.") | |
| print("=" * 60) | |
| return True | |
| if __name__ == "__main__": | |
| success = main() | |
| sys.exit(0 if success else 1) | |