MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / buildContentDisposition

Function buildContentDisposition

packages/server/src/routes/files.ts:309–319  ·  view source on GitHub ↗
(name: string, mediaType?: string)

Source from the content-addressed store, hash-verified

307}
308
309function buildContentDisposition(name: string, mediaType?: string): string {
310 // Media the browser can render (image/video/audio) is served `inline` so a
311 // direct navigation plays/displays it; everything else stays an attachment.
312 const kind = mediaType?.split('/')[0];
313 const disposition =
314 kind === 'image' || kind === 'video' || kind === 'audio' ? 'inline' : 'attachment';
315 if (/^[\w. ()+[\]-]+$/.test(name)) {
316 return `${disposition}; filename="${name}"`;
317 }
318 return disposition;
319}
320
321function readRangeHeader(value: string | string[] | undefined): string | undefined {
322 return Array.isArray(value) ? value[0] : value;

Callers 1

registerFilesRoutesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected