Class PromptBinaryData

java.lang.Object
de.xima.fc.prompt.service.defaults.PromptBinaryData

public final class PromptBinaryData extends Object
Provides common implementations of IPromptBinaryData.
Since:
8.5.0
  • Method Details

    • diskPromptBinaryData

      public static IPromptBinaryData diskPromptBinaryData(String fileName, String mimeType, Path content) throws IOException
      Creates an implementation of IPromptBinaryData backed by a file on the disk (file system).
      Parameters:
      fileName - The name of the file. Defaults to the name of the given Path when empty.
      mimeType - The MIME type of the file. Defaults to "application/octet-stream" when empty.
      content - The path to the file on the disk.
      Throws:
      IOException
    • emptyPromptBinaryData

      public static IPromptBinaryData emptyPromptBinaryData(String fileName, String mimeType)
      Creates an implementation of IPromptBinaryData representing an empty file.
      Parameters:
      fileName - The name of the file. Defaults to "data.bin" when empty.
      mimeType - The MIME type of the file. Defaults to "application/octet-stream" when empty.
      Returns:
      An implementation of IPromptBinaryData representing an empty file.
    • memoryPromptBinaryData

      public static IPromptBinaryData memoryPromptBinaryData(String fileName, String mimeType, Instant lastModified, byte[] content)
      Creates an implementation of IPromptBinaryData backed by a byte array in memory.
      Parameters:
      fileName - The name of the file. Defaults to "data.bin" when empty.
      mimeType - The MIME type of the file. Defaults to "application/octet-stream" when empty.
      lastModified - The last modified timestamp of the file. Defaults to the current time when null.
      content - The content of the file as a byte array. null is treated as empty content.
      Returns:
      An implementation of IPromptBinaryData backed by a byte array in memory.
    • supplierBinaryData

      public static IPromptBinaryData supplierBinaryData(String fileName, String mimeType, Instant lastModified, int fileSize, ISerializableInputStreamSupplier supplier)
      Creates an implementation of IPromptBinaryData backed by an input stream supplier.
      Parameters:
      fileName - The name of the file.
      mimeType - The MIME type of the file.
      lastModified - The last modified timestamp of the file.
      fileSize - The size of the file in bytes.
      supplier - The supplier for the input stream with the file content.
      Returns:
      An implementation of IPromptBinaryData backed by an input stream supplier.