INNER CODE UNIT · Python

api_upload

Nuclear-Marmalade/dataforge · forge/dashboard/app.py:567

async def api_upload(file: UploadFile = File(...)):
    """Handle CSV file upload.

    Security: uses secrets.token_hex for filenames, enforces MAX_UPLOAD_SIZE.
    """
    if not file.filename or not file.filename.endswith(".csv"):
        return HTMLResponse(
            '<div class="forge-card text-red-400 text-center py-4">Please upload a .csv file</div>'
        )

    db = _get_db()
    if not db:
        return HTMLResponse(
            '<div class="forge-card text-red-400 text-center py-4">Database not available</div>'
        )

    # Security: random filename via secrets.token_hex, size check via MAX_UPLOAD_SIZE
    tmp_path = tmp_dir = ""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…