Class PromptConfigFile
java.lang.Object
de.xima.fc.prompt.service.support.PromptConfigFile
- All Implemented Interfaces:
Serializable
View model for a single file, intended to be used as part of the
deserialized prompt connection
configuration or deserialized prompt
query configuration.- Since:
- 8.5.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty file with 0 bytes.Creates a new file preloaded with the content of the given binary data.PromptConfigFile(String fileName, String mimeType, Path content) Creates a new file preloaded with the content of the file at the given path.PromptConfigFile(String fileName, String mimeType, Instant lastModified, byte[] data) Creates a new file with the given name, MIME type, and binary data.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. -
Method Summary
Modifier and TypeMethodDescriptionOpens an input stream to the file content.Gets the name of the file, e.g.intGets the size of the file in bytes.Gets the time the file was last modified.Gets the MIME type of the file, e.g.voidsetFileContent(byte[] data) Sets the file content to a byte array.voidSets the file content to the given binary data.voidsetFileContent(Path path) Sets the file content to a file at the given path.voidsetFileName(String fileName) Sets the name of the file, e.g.voidsetFileSize(int fileSize) Sets the size of the file in bytes.voidsetLastModified(Instant lastModified) Sets the time the file was last modified.voidsetMimeType(String mimeType) Sets the MIME type of the file, e.g.
-
Constructor Details
-
PromptConfigFile
public PromptConfigFile()Creates a new empty file with 0 bytes. -
PromptConfigFile
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
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 givenPathwhen 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
Creates a new file preloaded with the content of the given binary data.- Parameters:
data- The binary data to preload
-
-
Method Details
-
getFileContent
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
Sets the file content to a file at the given path.- Parameters:
path- The path to the file that contains the new content.
-
setFileContent
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
Gets the name of the file, e.g. "image.png".- Returns:
- The name of the file.
-
setFileName
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
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
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
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
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.
-