function serveUploadedFile
serveUploadedFile(
ctx: Context,
filePath: string,
mime: string,
cacheMaxAge?: number,
isPrivate?: boolean,
defaultWidth?: ImageWidth
): Promise<boolean>

Serves an uploaded image inline as mime, or scaled down as serveImage does, cached for cacheMaxAge seconds, and only by the browser when isPrivate. It answers 404 and resolves false when the file is missing. The caller checks first that the viewer may see it.

Parameters

ctx: Context
filePath: string
mime: string
optional
cacheMaxAge: number = 3600
optional
isPrivate: boolean = false
optional
defaultWidth: ImageWidth

Return Type

Promise<boolean>

Usage

import { serveUploadedFile } from "api/lib/upload.ts";