docs: private int getAvailableSize(Object inputStream, int expectedReadSize) throws IOException, InternalException {
      RandomAccessFile file = null;
      BufferedInputStream stream = null;
      if (inputStream instanceof RandomAccessFile) {
        file = (RandomAccessFile) inputStream;
      } else if (inputStream instanceof BufferedInputStream) {
        stream = (BufferedInputStream) inputStream;
      } else {
        throw new InternalException("Unknown input stream. This should not happen.  "
                                    + "Please report to https://github.com/minio/minio-java/issues/");
      }
  
      // hold current position of file/stream to reset back to this position.
      long pos = 0;
      if (file != null) {
        pos = file.getFilePointer();
      } else {
        stream.mark(expectedReadSize);
      }
  
      // 16KiB buffer for optimization
      byte[] buf = new byte[16384];
      int bytesToRead = buf.length;
      int bytesRead = 0;
      int totalBytesRead = 0;
      while (totalBytesRead < expectedReadSize) {
        if ((expectedReadSize - totalBytesRead) < bytesToRead) {
          bytesToRead = expectedReadSize - totalBytesRead;
        }
  
        if (file != null) {
          bytesRead = file.read(buf, 0, bytesToRead);
        } else {
          bytesRead = stream.read(buf, 0, bytesToRead);
        }
  
        if (bytesRead < 0) {
          // reached EOF
          break;
        }
  
        totalBytesRead += bytesRead;
      }
  
      // reset back to saved position.
      if (file != null) {
        file.seek(pos);
      } else {
        stream.reset();
      }
  
      return totalBytesRead;
    }