Class PromptBinaryData
java.lang.Object
de.xima.fc.prompt.service.defaults.PromptBinaryData
Provides common implementations of
IPromptBinaryData.- Since:
- 8.5.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic IPromptBinaryDatadiskPromptBinaryData(String fileName, String mimeType, Path content) Creates an implementation ofIPromptBinaryDatabacked by a file on the disk (file system).static IPromptBinaryDataemptyPromptBinaryData(String fileName, String mimeType) Creates an implementation ofIPromptBinaryDatarepresenting an empty file.static IPromptBinaryDatamemoryPromptBinaryData(String fileName, String mimeType, Instant lastModified, byte[] content) Creates an implementation ofIPromptBinaryDatabacked by a byte array in memory.static IPromptBinaryDatasupplierBinaryData(String fileName, String mimeType, Instant lastModified, int fileSize, ISerializableInputStreamSupplier supplier) Creates an implementation ofIPromptBinaryDatabacked by an input stream supplier.
-
Method Details
-
diskPromptBinaryData
public static IPromptBinaryData diskPromptBinaryData(String fileName, String mimeType, Path content) throws IOException Creates an implementation ofIPromptBinaryDatabacked by a file on the disk (file system).- 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.- Throws:
IOException
-
emptyPromptBinaryData
Creates an implementation ofIPromptBinaryDatarepresenting 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
IPromptBinaryDatarepresenting an empty file.
-
memoryPromptBinaryData
public static IPromptBinaryData memoryPromptBinaryData(String fileName, String mimeType, Instant lastModified, byte[] content) Creates an implementation ofIPromptBinaryDatabacked 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
IPromptBinaryDatabacked by a byte array in memory.
-
supplierBinaryData
public static IPromptBinaryData supplierBinaryData(String fileName, String mimeType, Instant lastModified, int fileSize, ISerializableInputStreamSupplier supplier) Creates an implementation ofIPromptBinaryDatabacked 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
IPromptBinaryDatabacked by an input stream supplier.
-