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

Function createFileResponse

apps/sim/app/api/files/utils.ts:208–223  ·  view source on GitHub ↗
(file: FileResponse)

Source from the content-addressed store, hash-verified

206}
207
208export function createFileResponse(file: FileResponse): NextResponse {
209 const { contentType, disposition } = getSecureFileHeaders(file.filename, file.contentType)
210
211 const headers: Record<string, string> = {
212 'Content-Type': contentType,
213 'Content-Disposition': `${disposition}; ${encodeFilenameForHeader(file.filename)}`,
214 'Cache-Control': file.cacheControl || 'public, max-age=31536000',
215 'X-Content-Type-Options': 'nosniff',
216 }
217
218 if (contentType === 'image/svg+xml') {
219 headers['Content-Security-Policy'] = "default-src 'none'; style-src 'unsafe-inline'; sandbox;"
220 }
221
222 return new NextResponse(file.buffer as BodyInit, { status: 200, headers })
223}
224
225export function createErrorResponse(error: Error, status = 500): NextResponse {
226 const statusCode =

Callers 7

serveInlineImageFunction · 0.90
utils.test.tsFile · 0.90
route.tsFile · 0.90
handleLocalFileFunction · 0.90
handleCloudProxyFunction · 0.90
handleCloudProxyPublicFunction · 0.90
handleLocalFilePublicFunction · 0.90

Calls 2

getSecureFileHeadersFunction · 0.85
encodeFilenameForHeaderFunction · 0.85

Tested by

no test coverage detected