private TikaInputStream transformRawStream(TikaInputStream is) throws IOException {
        if (config.getUnfilteredStreamTransformer() != null) {
            if (is.getLength() < 10000000) {
                try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
                    config.getUnfilteredStreamTransformer().transform(is, bos);
                    bos.flush();
                    bos.close();
                    return TikaInputStream.get(bos.toByteArray());
                } catch (TikaException e) {
                    throw new IOException(e);
                }
            } else {
                TemporaryResources tmp = new TemporaryResources();
                Path p = tmp.createTempFile();
                try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(p))) {
                    config.getUnfilteredStreamTransformer().transform(is, os);
                    os.flush();
                } catch (TikaException e) {
                    throw new IOException(e);
                }
                return TikaInputStream.get(p, new Metadata(), tmp);
            }
        }
        return is;
    }
This will write the body of the document.

@param doc The document to write the body for.
@throws IOException If there is an error writing the data.
tika-fuzzing/src/main/java/org/apache/tika/fuzzing/pdf/EvilCOSWriter.java