in flume-morphline-solr-sink/src/main/java/org/apache/flume/sink/solr/morphline/BlobHandler.java [76:106]
public List<Event> getEvents(HttpServletRequest request) throws Exception {
Map<String, String> headers = getHeaders(request);
InputStream in = request.getInputStream();
try {
ByteArrayOutputStream blob = null;
byte[] buf = new byte[Math.min(maxBlobLength, DEFAULT_BUFFER_SIZE)];
int blobLength = 0;
int n = 0;
while ((n = in.read(buf, 0, Math.min(buf.length, maxBlobLength - blobLength))) != -1) {
if (blob == null) {
blob = new ByteArrayOutputStream(n);
}
blob.write(buf, 0, n);
blobLength += n;
if (blobLength >= maxBlobLength) {
LOGGER.warn("Request length exceeds maxBlobLength ({}), truncating BLOB event!",
maxBlobLength);
break;
}
}
byte[] array = blob != null ? blob.toByteArray() : new byte[0];
Event event = EventBuilder.withBody(array, headers);
if (LOGGER.isDebugEnabled() && LogPrivacyUtil.allowLogRawData()) {
LOGGER.debug("blobEvent: {}", event);
}
return Collections.singletonList(event);
} finally {
in.close();
}
}