Record Class Attachment

java.lang.Object
java.lang.Record
win.dailypickle.report.model.Attachment
Record Components:
name - the display name passed to scenario.attach(data, mediaType, name), or null when the caller did not provide one (reports fall back to the MIME type)
mimeType - the MIME type declared at attach time (e.g. "image/png", "application/json", "text/plain")
data - Base64-encoded attachment content, or null when the attachment is external
path - path of the attachment file relative to the report directory, or null when the attachment is inline
sizeBytes - size of the raw (un-encoded) payload in bytes

public record Attachment(String name, String mimeType, String data, String path, long sizeBytes) extends Record
An attachment captured from a scenario.attach() call during step or hook execution.

Attachments are stored in one of two ways, decided at capture time by the payload size:

  • Inline — payloads up to the configured inline limit (default 4 KiB, see dailypickle.attachments.inlineLimit) are Base64-encoded into data; path is null. Binary payloads (e.g. screenshots) are encoded directly; text payloads are UTF-8–encoded then Base64-encoded.
  • External — larger payloads are streamed to a file next to the report as soon as they are attached, so they never accumulate on the heap. path holds the file's location relative to the report directory (forward slashes); data is null.

The HTML report embeds every attachment so the single file stays portable: inline images and text render directly (with syntax highlighting), external payloads are re-streamed from disk into the document at generation time (images as data: URIs, text as plain code blocks, other types as data: URI download links). The Markdown report includes only LLM-readable MIME types (text/* except text/html, application/json, application/xml, application/yaml), reading small external files back from disk.

Note: scenario.log() output is not captured — use scenario.attach() with a text MIME type instead.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Attachment(String name, String mimeType, String data, String path, long sizeBytes)
    Creates an instance of a Attachment record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the data record component.
    Name when provided, MIME type otherwise — what reports show as the attachment's label.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static Attachment
    external(String name, String mimeType, String path, long sizeBytes)
    Creates an external attachment stored on disk at path relative to the report dir.
    final int
    Returns a hash code value for this object.
    static Attachment
    inline(String name, String mimeType, String base64Data, long sizeBytes)
    Creates an inline attachment whose Base64 content is carried in the report model.
    boolean
    True when the payload lives on disk rather than in the report model.
    Returns the value of the mimeType record component.
    Returns the value of the name record component.
    Returns the value of the path record component.
    long
    Returns the value of the sizeBytes record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Attachment

      public Attachment(String name, String mimeType, String data, String path, long sizeBytes)
      Creates an instance of a Attachment record class.
      Parameters:
      name - the value for the name record component
      mimeType - the value for the mimeType record component
      data - the value for the data record component
      path - the value for the path record component
      sizeBytes - the value for the sizeBytes record component
  • Method Details

    • inline

      public static Attachment inline(String name, String mimeType, String base64Data, long sizeBytes)
      Creates an inline attachment whose Base64 content is carried in the report model.
    • external

      public static Attachment external(String name, String mimeType, String path, long sizeBytes)
      Creates an external attachment stored on disk at path relative to the report dir.
    • isExternal

      public boolean isExternal()
      True when the payload lives on disk rather than in the report model.
    • displayName

      public String displayName()
      Name when provided, MIME type otherwise — what reports show as the attachment's label.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • mimeType

      public String mimeType()
      Returns the value of the mimeType record component.
      Returns:
      the value of the mimeType record component
    • data

      public String data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component
    • path

      public String path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • sizeBytes

      public long sizeBytes()
      Returns the value of the sizeBytes record component.
      Returns:
      the value of the sizeBytes record component