INNER CODE UNIT · Python

MAX_UPLOAD_SIZE

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

MAX_UPLOAD_SIZE = 100 * 1024 * 1024  # 100 MB


async def _save_upload_to_temp(file: UploadFile) -> tuple:
    """Stream upload to temp file. Returns (tmp_path, tmp_dir) or raises."""
    tmp_dir = tempfile.mkdtemp(prefix="forge_upload_")
    safe_name = secrets.token_hex(8) + ".csv"
    tmp_path = os.path.join(tmp_dir, safe_name)
    total = 0
    with open(tmp_path, "wb") as f:
        while True:
            chunk = await file.read(8192)
            if not chunk:
                break
            total += len(chunk)
            if total > MAX_UPLOAD_SIZE:
                f.close()
                os.unlink(tmp_path)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…