Class Binary.BinaryStream

java.lang.Object
org.rapidcontext.core.data.Binary.BinaryStream
All Implemented Interfaces:
Binary
Enclosing interface:
Binary

public static class Binary.BinaryStream extends Object implements Binary
A binary data object, encapsulating an input stream. This wrapper breaks the Binary contract slightly, since new streams cannot be opened.
Version:
1.0
  • Constructor Details

    • BinaryStream

      public BinaryStream(InputStream is, int size)
      Creates a new binary stream wrapper.
      Parameters:
      is - the input stream to encapsulate
      size - the size (in bytes), or -1 if unknown
  • Method Details

    • size

      public long size()
      Returns the size (in bytes) of the binary object, if known.
      Specified by:
      size in interface Binary
      Returns:
      the object size (in bytes), or -1 if unknown
    • lastModified

      public long lastModified()
      The last modified timestamp for the object, if known.
      Specified by:
      lastModified in interface Binary
      Returns:
      the last modified timestamp, or zero (0) or the current system if unknown
    • mimeType

      public 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.
      Specified by:
      mimeType in interface Binary
      Returns:
      the MIME type of the binary data
    • sha256

      public String sha256()
      The SHA-256 of the binary data, if known.
      Specified by:
      sha256 in interface Binary
      Returns:
      the hexadecimal string with the SHA-256 hash, or null if not available
    • openStream

      public InputStream openStream() throws IOException
      Opens a new input stream for reading the data.
      Specified by:
      openStream in interface Binary
      Returns:
      a new input stream for reading the binary data
      Throws:
      IOException - if the data couldn't be opened for reading