Table of Contents

Class Attachment

Namespace
LMKit.Data
Assembly
LM-Kit.NET.dll

Represents a file attachment with its content, name, MIME type, and size.

Supported Formats: PNG, BMP, GIF, PSD, PIC, JPEG, PNM, HDR, TGA, WEBP, TIFF, TXT, HTML.

public sealed class Attachment : IDisposable
Inheritance
Attachment
Implements
Inherited Members

Constructors

Attachment(byte[], string)

Initializes a new instance of the Attachment class with the provided data and name. The data must represent one of the supported image formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT
Attachment(Stream, string)

Initializes a new instance of the Attachment class by reading the content from the provided stream and using the given file name. The stream must contain data representing one of the supported image formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT
Attachment(string)

Initializes a new instance of the Attachment class by loading the content from the specified file path. The file must be one of the supported image formats:

  • PNG
  • BMP
  • GIF
  • PSD
  • PIC
  • JPEG
  • PNM
  • HDR
  • TGA
  • WEBP
  • TIFF
  • HTML
  • TXT

Properties

HasText

Gets a value indicating whether the attachment contains extractable text.

IsVisionRequired

Gets a value indicating whether vision processing (e.g., image analysis or OCR) is required to interpret the attachment.

Length

Gets the length of the attachment content in bytes.

Mime

Gets the MIME type of the attachment.

Name

Gets the name of the attachment file.

Path

Gets the full file-system path from which this attachment was loaded.

Methods

CreateFromBase64String(string, string)

Creates a new Attachment instance from a base64-encoded string.

CreateFromText(string, string)

Creates a new Attachment instance from a plain-text string.

DetectMimeType(byte[])

Detects the MIME type of the provided byte array, using only the formats supported by the LMKit toolkit.

DetectMimeType(string)

Detects the MIME type of the file at the specified path, using only the formats supported by the LM-Kit toolkit.

Dispose()

Releases all resources used by the attachment.

GetText(CancellationToken)

Extracts and returns the textual content from the attachment.

GetTextAsync(CancellationToken)

Asynchronously extracts and returns the textual content from the attachment.

SetText(string)

Attaches a textual representation to the attachment. This is primarily used to supply or override the extracted text for raster-based attachments (e.g., images), where OCR or other vision processing may be applied.

ToString()

Returns the textual content of the attachment.