Package org.rapidcontext.core.data
Interface Binary
- All Known Implementing Classes:
Binary.BinaryFile
,Binary.BinaryStream
,Binary.BinaryString
public interface Binary
A binary data object, similar to a file on a file system. This
interface is used to abstract away the file system when data is
retrieved via the Storage API.
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
A binary data object, encapsulating a file.static class
A binary data object, encapsulating an input stream.static class
A binary data object, encapsulating a string. -
Method Summary
Modifier and TypeMethodDescriptionlong
The last modified timestamp for the object, if known.mimeType()
The MIME type of the binary data.Opens a new input stream for reading the data.sha256()
The SHA-256 of the binary data, if known.long
size()
Returns the size (in bytes) of the binary object, if known.
-
Method Details
-
size
long size()Returns the size (in bytes) of the binary object, if known.- Returns:
- the object size (in bytes), or -1 if unknown
-
lastModified
long lastModified()The last modified timestamp for the object, if known.- Returns:
- the last modified timestamp, or zero (0) or the current system if unknown
-
mimeType
String mimeType()The MIME type of the binary data. Use a standard opaque binary data MIME type or one based on requested file name if unknown.- Returns:
- the MIME type of the binary data
-
sha256
String sha256()The SHA-256 of the binary data, if known.- Returns:
- the hexadecimal string with the SHA-256 hash, or null if not available
-
openStream
Opens a new input stream for reading the data. Note that this method SHOULD be possible to call several times.- Returns:
- a new input stream for reading the binary data
- Throws:
IOException
- if the data couldn't be opened for reading
-