Media / foldkit-media/server

FileUploadPolicy

class · packages/media/src/server/files.ts:40

class FileUploadPolicy extends Context.Service<
  FileUploadPolicy,
  {
    readonly admit: (
      request: HttpServerRequest.HttpServerRequest,
    ) => Effect.Effect<string, UploadForbidden | UploadUnauthenticated>
  }
>()('foldkit-media/FileUploadPolicy') {}

Who may upload a file, asked before the body is read, answering the uploader's id: only that id may later claim the file. It must be stable and never given to anyone else; an empty id is refused. No default, so a server is never open to uploads by omission.