Interface IPromptFileStorage


public interface IPromptFileStorage
Storage used during prompt execution to store binary data. Frees users from having to manage temporary files themselves. The implementation will choose an appropriate storage mechanism (such as storing small files in memory and larger files on disk), and will take care of cleaning up the stored data when it is no longer needed, e.g. after the prompt was executed.

You could just store the data in memory, but that risks filling up the RAM. You could also create a new temporary file on the file system to store the data, but that risks filling up the disk as the file would never be deleted. Prefer using the methods provided by this file storage store instead, as the implementation can decide how to best store and clean up the data.

Since:
8.5.0
  • Method Details

    • storeBinaryData

      IPromptStoredData storeBinaryData(InputStream inputStream) throws IOException
      Stores the given binary data and returns a supplier that can be used to read the data later. The returned supplier is serializable and can be used multiple times to read the data.
      Parameters:
      inputStream - The input stream containing the binary data to store.
      Returns:
      A supplier that can be used to read the stored binary data.
      Throws:
      IOException - If an I/O error occurs while storing the data.
    • storeBinaryData

      IPromptStoredData storeBinaryData(IPromptFileWriter writer) throws IOException
      Provides an output stream to the given writer that can be used to write binary data to be stored. The writer will be invoked with an output stream that writes to the storage. After the writer has finished writing, the stored data can be accessed via the returned IPromptStoredData instance.
      Parameters:
      writer - The writer that will write the binary data to the provided output stream.
      Returns:
      A IPromptStoredData instance that can be used to read the stored binary data.
      Throws:
      IOException - If an I/O error occurs while storing the data.