MCPcopy Index your code
hub / github.com/simstudioai/sim / readFormDataWithLimit

Function readFormDataWithLimit

apps/sim/lib/core/utils/stream-limits.ts:67–84  ·  view source on GitHub ↗
(
  request: ReadFormDataWithLimitRequest,
  options: { maxBytes: number; label: string }
)

Source from the content-addressed store, hash-verified

65}
66
67export async function readFormDataWithLimit(
68 request: ReadFormDataWithLimitRequest,
69 options: { maxBytes: number; label: string }
70): Promise<FormData> {
71 assertContentLengthWithinLimit(request.headers, options.maxBytes, options.label)
72
73 if (request.headers?.get('content-length') || !request.body) {
74 return request.formData()
75 }
76
77 const body = await readStreamToBufferWithLimit(request.body, options)
78 const boundedRequest = new Request(request.url, {
79 method: request.method,
80 headers: request.headers,
81 body: new Uint8Array(body),
82 })
83 return boundedRequest.formData()
84}
85
86export interface ReadStreamWithLimitOptions {
87 maxBytes: number

Callers 3

route.tsFile · 0.90
route.tsFile · 0.90

Calls 3

getMethod · 0.65

Tested by

no test coverage detected