@Override public String mimeTypeOf( final String name, final Binary binaryValue ) throws RepositoryException, IOException { Metadata metadata = new Metadata(); if (!StringUtil.isBlank(name)) { metadata.set(Metadata.RESOURCE_NAME_KEY, name); } if (binaryValue == null) { return name == null ? null : detect(null, metadata); } InputStream stream = binaryValue.getStream(); if (stream instanceof SelfClosingInputStream) { //we need to avoid the SelfClosingInputStream because Tika will read and mark from this stream multiple times stream = ((SelfClosingInputStream)stream).wrappedStream(); } return detect(stream, metadata); }
@Override public String mimeTypeOf( final String name, final Binary binaryValue ) throws RepositoryException, IOException { Metadata metadata = new Metadata(); if (!StringUtil.isBlank(name)) { metadata.set(Metadata.RESOURCE_NAME_KEY, name); } if (binaryValue == null) { return name == null ? null : detect(null, metadata); } InputStream stream = binaryValue.getStream(); if (stream instanceof SelfClosingInputStream) { //we need to avoid the SelfClosingInputStream because Tika will read and mark from this stream multiple times stream = ((SelfClosingInputStream)stream).wrappedStream(); } return detect(stream, metadata); }