# Cloudflare R2 Upload & Asset Management Scripts This directory contains utility scripts for synchronizing media, audio, and Tafseer data assets to the Cloudflare R2 object storage bucket (`sahihislam`). ## Prerequisites - **Wrangler CLI** installed globally (`npm install -g wrangler`) or available via `npx wrangler`. - Cloudflare credentials configured in your `BACKEND/.env` file: - `CLOUDFLARE_API_TOKEN` - `CLOUDFLARE_ACCOUNT_ID` - `R2_ACCESS_KEY_ID` - `R2_SECRET_ACCESS_KEY` ## Directory Contents | File | Purpose | | :--- | :--- | | `UPLOAD_NIMAZ_TO_R2.ps1` | Uploads Nimaz Mutarjam recitation, translation, and heading audio files to `sahihislam/Nimaz_Mutarjam_audio/`. | | `UPLOAD_QAIDA_TO_R2.ps1` | Uploads Noorani Qaida letter and numbered audio files to `sahihislam/qaida_audio/`. | | `upload_tafseer_to_r2.ps1` | Batch uploads Quran Tafseer structured JSON datasets to `sahihislam/quran_tafseer/`. | | `upload_translations_to_r2.ps1` | Batch uploads multilingual Quran translations to Cloudflare R2. | | `upload_files_to_r2.ps1` | General-purpose batch upload script with rate-limiting and progress tracking. | | `upload_to_r2_remote.ps1` | Direct API-based uploader for remote environments without local Wrangler credentials. | | `r2-cors-config.json` | S3-compatible CORS configuration for R2 bucket web client access. | | `test_r2_integration.py` | Integration test verifying R2 public CDN connectivity, HTTP headers, and Tafseer availability. | ## Running the Verification Script To verify your R2 bucket connectivity from the backend root: ```bash python BACKEND/scripts/r2_upload/test_r2_integration.py ```