← Public packages
@kentcdodds/agent-files
Mint short-lived R2 PUT URLs for agent file handoffs; public download via managed r2.dev.
src/upload.ts
23 lines · 860 B · TypeScriptimport { uploadFile } from './lib/files.ts'
import type { UploadInput } from './lib/files.ts'
/**
* Small-file escape hatch: PUT bytes through MCP params (`bytesBase64` / `base64`).
* Prefer `./create-upload` for anything beyond a few hundred KB — MCP payloads are size-limited.
* Auto-rejects when decoded size exceeds the MCP-safe limit.
*
* @param input - `filename` plus bytes (`bytesBase64` / `base64` / …); optional `contentType` / `prefix`; requires `confirm: true`
* @returns `{ key, downloadUrl, size, contentType }`
*
* @example
* import upload from 'kody:@kentcdodds/agent-files/upload'
* const result = await upload({
* filename: 'tiny.txt',
* contentType: 'text/plain',
* bytesBase64: btoa('hello'),
* confirm: true,
* })
*/
export default async function uploadExport(input: UploadInput) {
return uploadFile(input)
}