Media / foldkit-media/server

uploadHandlers

function · packages/media/src/server/upload.ts:98

function uploadHandlers(
  options?: UploadOptions,
): Layer.Layer<
  HttpApiGroup.Service<'foldkit-media-upload', 'uploads'>,
  never,
  Inspector | UploadPolicy | Uploads
>

The upload route's handler. It asks the UploadPolicy first; takes only an image/* body, which a browser cannot send to another origin without a preflight this route never answers, so a cookie alone cannot upload from another site; reads at most maxBytes; and refuses what the Inspector cannot read as an image (415). Its answer is the facts, with the hash as the key, 201.