code: public static Flowable<byte[]> from(final InputStream is, final int bufferSize) {
          return Flowable.generate(new Consumer<Emitter<byte[]>>() {
              @Override
              public void accept(Emitter<byte[]> emitter) throws Exception {
                  byte[] buffer = new byte[bufferSize];
                  int count = is.read(buffer);
                  if (count == -1) {
                      emitter.onComplete();
                  } else if (count < bufferSize) {
                      emitter.onNext(Arrays.copyOf(buffer, count));
                  } else {
                      emitter.onNext(buffer);
                  }
              }
          });
      }
docs: Returns a Flowable stream of byte arrays from the given
  {@link InputStream} between 1 and {@code bufferSize} bytes.
  
  @param is
  input stream of bytes
  @param bufferSize
  max emitted byte array size
  @return a stream of byte arrays