Class PromptConfigFile

    • Constructor Detail

      • PromptConfigFile

        public PromptConfigFile()
        Creates a new empty file with 0 bytes.
      • PromptConfigFile

        public PromptConfigFile​(String fileName,
                                String mimeType,
                                Instant lastModified,
                                byte[] data)
        Creates a new file with the given name, MIME type, and binary data.
        Parameters:
        fileName - The name of the file, e.g. "image.png". If empty, defaults to "data".
        mimeType - The MIME type of the file, e.g. "image/png". If empty, defaults to "application/octet-stream".
        data - The binary data to preload. If null, the file will be empty with 0 bytes.
      • PromptConfigFile

        public PromptConfigFile​(String fileName,
                                String mimeType,
                                Instant lastModified,
                                int fileSize,
                                ISerializableInputStreamSupplier data)
        Creates a new file with the given name, MIME type, last modified date, and binary data.
        Parameters:
        fileName - The name of the file, e.g. "image.png". If empty, defaults to "data".
        mimeType - The MIME type of the file, e.g. "image/png". If empty, defaults to "application/octet-stream".
        lastModified - The last modified timestamp of the file. If null, defaults to the current time.
        fileSize - The size of the file in bytes.
        data - The binary data to preload. If null, the file will be empty with 0 bytes.
      • PromptConfigFile

        public PromptConfigFile​(String fileName,
                                String mimeType,
                                Path content)
        Creates a new file preloaded with the content of the file at the given path.
        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.
      • PromptConfigFile

        public PromptConfigFile​(IPromptBinaryData data)
        Creates a new file preloaded with the content of the given binary data.
        Parameters:
        data - The binary data to preload
    • Method Detail

      • getFileContent

        public InputStream getFileContent()
                                   throws IOException
        Opens an input stream to the file content.
        Returns:
        An input stream to the file content, or an empty input stream if no content is set.
        Throws:
        IOException
      • setFileContent

        public void setFileContent​(Path path)
        Sets the file content to a file at the given path.
        Parameters:
        path - The path to the file that contains the new content.
      • setFileContent

        public void setFileContent​(IPromptBinaryData data)
        Sets the file content to the given binary data.
        Parameters:
        data - The binary data to set as the file content.
      • setFileContent

        public void setFileContent​(byte[] data)
        Sets the file content to a byte array. Use with caution, as this will keep the entire byte array in memory.
        Parameters:
        data - The byte array to set as file content.
      • getFileName

        public String getFileName()
        Gets the name of the file, e.g. "image.png".
        Returns:
        The name of the file.
      • setFileName

        public void setFileName​(String fileName)
        Sets the name of the file, e.g. "image.png".
        Parameters:
        fileName - The name of the file.
      • getFileSize

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

        public void setFileSize​(int fileSize)
        Sets the size of the file in bytes.
        Parameters:
        fileSize - The size of the file.
      • getLastModified

        public Instant getLastModified()
        Gets the time the file was last modified. For newly created files, this is the time of creation.
        Returns:
        The last modified timestamp of the file.
      • setLastModified

        public void setLastModified​(Instant lastModified)
        Sets the time the file was last modified. For newly created files, this is the time of creation.
        Parameters:
        lastModified - The last modified timestamp of the file.
      • getMimeType

        public String getMimeType()
        Gets the MIME type of the file, e.g. "image/png". When the content is plain text, should contain the encoding as well, e.g. "text/plain; charset=UTF-8". If no encoding is specified, the default is UTF-8. When no MIME type is set, the system may try to detect the type or default to "application/octet-stream".
        Returns:
        The MIME type of the file.
      • setMimeType

        public void setMimeType​(String mimeType)
        Sets the MIME type of the file, e.g. "image/png". When the content is plain text, should contain the encoding as well, e.g. "text/plain; charset=UTF-8". If no encoding is specified, the default is UTF-8. When no MIME type is set, the system may try to detect the type or default to "application/octet-stream".
        Parameters:
        mimeType - The MIME type of the file.