Skip to main content
Convert a photo-content input into the discriminated PhotoAction shape.
  • "clear" → { kind: "clear" } (reserved sentinel — to send a literal file named clear, pass "./clear" or load it as a Buffer).
  • string path → reads the file lazily via node:fs/promises.readFile; MIME type inferred from the filename extension.
  • URL → fetched lazily over the network into memory; never touches the filesystem, so it works in read-only environments. MIME type is inferred from the URL pathname extension at build time (override with options.mimeType if the URL has no usable extension).
  • Buffer → in-memory bytes; options.mimeType is required.
Called at builder-construction time so a missing MIME type fails fast rather than at send time. The returned read() is memoized so repeated build() / send cycles don’t re-read the same file.