throw new CmisInvalidArgumentException("Limit exceeded!");
}
}
private void readBodyAsStream() throws IOException {
ThresholdOutputStream stream = new ThresholdOutputStream(tempDir, memoryThreshold, maxContentSize, encrypt);
try {
while (true) {
readBuffer();
int boundaryPosition = findBoundary();
if (boundaryPosition > -1) {
stream.write(buffer, bufferPosition, boundaryPosition - bufferPosition);
bufferPosition = boundaryPosition + boundary.length;
break;
} else {
int len = Math.min(BUFFER_SIZE, bufferCount) - bufferPosition;
stream.write(buffer, bufferPosition, len);
bufferPosition = bufferPosition + len;
}
}
stream.close();
contentSize = BigInteger.valueOf(stream.getSize());
contentStream = stream.getInputStream();
} catch (IOException e) {
// if something went wrong, make sure the temp file will
// be deleted
stream.destroy();
throw e;
}
}