@echo off
rem ============================================================
rem AtoLog Uploader (Windows)
rem ============================================================
rem How to use:
rem   1. Place this file in the same folder as atolog_upload.setting
rem   2. Drag and drop a PDF file onto this script
rem ============================================================

rem --- Read atolog_upload.setting ---
set SETTING_FILE=%~dp0atolog_upload.setting
set DOMAIN=
set API_KEY=

for /f "usebackq tokens=1,2 delims=^=" %%a in ("%SETTING_FILE%") do (
    if "%%a"=="DOMAIN" set DOMAIN=%%b
    if "%%a"=="API_KEY" set API_KEY=%%b
)

if "%DOMAIN%"=="" (
    echo Error: atolog_upload.setting not found or DOMAIN not set.
    pause
    exit /b 1
)

if "%~1"=="" (
    echo Usage: Drag and drop a PDF file onto this script.
    pause
    exit /b 1
)

echo Uploading: %~1
curl -X POST "https://%DOMAIN%/api/upload" -H "X-API-Key: %API_KEY%" -F file=@%1

echo.
echo Done. The share_url above is your shareable link.
pause
