Class FileContent

java.lang.Object
de.xima.fc.prompt.ms.impl.service.generic_oai.client.model.FileContent

public final class FileContent extends Object
Represents a file to be sent to the generic OAI endpoint or a file that was received from it.
Since:
8.5.0
  • Method Details

    • fileName

      public String fileName()
      Gets the name of the file.
      Returns:
      The file name.
    • fileSize

      public int fileSize()
      Gets the size of the file in bytes.
      Returns:
      The file size.
    • inputStream

      public SerializableInputStreamSupplier inputStream()
      Gets the supplier of the input stream containing the file's binary data.
      Returns:
      The input stream supplier.
    • mimeType

      public String mimeType()
      Gets the mime type of the file.
      Returns:
      The mime type.
    • fromFile

      public static FileContent fromFile(String mimeType, Path file) throws IOException
      Creates a new file from the given file path. Uses the file name of the given file.
      Parameters:
      mimeType - The mime type of the file.
      file - The path to the file.
      Returns:
      A new file instance.
      Throws:
      IOException - If an I/O error occurs reading the file size.
    • fromString

      public static FileContent fromString(String fileName, String mimeType, String data, Charset charset)
      Creates a new file with the given file name, mime type and string data.
      Parameters:
      fileName - The name of the file.
      mimeType - The mime type of the file.
      data - The string data of the file.
      charset - The charset to encode the string data.
      Returns:
      A new file instance.
    • fromSupplier

      public static FileContent fromSupplier(String fileName, String mimeType, int fileSize, SerializableInputStreamSupplier inputStream)
      Creates a new file with the given file name, mime type and binary data.
      Parameters:
      fileName - The name of the file.
      mimeType - The mime type of the file.
      fileSize - The size of the file in bytes.
      inputStream - The supplier of the input stream containing the file's binary data.
      Returns:
      A new file instance.