// Automatically detect the MIME type of the document
MediaType type = detector.detect(stream, metadata);
metadata.set(Metadata.CONTENT_TYPE, type.toString());
// TIKA-216: Zip bomb prevention
CountingInputStream count = new CountingInputStream(stream);
SecureContentHandler secure = new SecureContentHandler(handler, count);
// Parse the document
try {
super.parse(count, secure, metadata, context);