Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xsline OpenChatCut UploadPlugin

From Leeroopedia
Knowledge Sources
Domains Media_Import, HTTP, Upload
Last Updated 2026-10-22 14:00 GMT

Overview

Concrete Vite plugin that registers HTTP routes for local file uploads, R2 hydration/presigning, media serving, and remote media import.

Description

The uploadPlugin function is a thin Vite plugin wrapper that delegates to `registerUploadRoutes` to set up all upload-related HTTP routes. It is the entry point for the media receipt stage of the import pipeline when files arrive via HTTP multipart upload.

The plugin registers routes for:

  • Local upload: Multipart file upload to the upload directory.
  • Media serving: Serving files from `/media/uploads/`.
  • R2 hydration/presign: Cloudflare R2 integration for remote storage.
  • Remote import: Importing media from remote URLs.

Usage

  • Server setup: Included in the server plugin chain in `server/plugins/index.ts`.
  • Desktop server: Used by the Electron embedded server for media uploads.

Code Reference

Source Location

  • Repository: OpenChatCut
  • File:*** server/plugins/upload.ts

Signature

import type { Plugin } from 'vite';
import { registerUploadRoutes } from './upload-routes.ts';

export { maxUploadBytes } from './upload-routes.ts';

export function uploadPlugin(): Plugin;

Import

import { uploadPlugin } from '../server/plugins/upload.ts';

I/O Contract

Inputs

Name Type Required Description
server ViteDevServer Yes Vite dev server (provided by plugin system)

Outputs

Name Type Description
Plugin Plugin Vite plugin object with name 'openchatcut-upload'

Usage Examples

Register Upload Routes

import { uploadPlugin } from '../server/plugins/upload.ts';

// In the server plugin chain
const plugins = [
  uploadPlugin(),
  // ...other plugins
];

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment