public static TikaInputStream get(Path path, Metadata metadata) throws IOException {
        if (StringUtils.isBlank(metadata.get(TikaCoreProperties.RESOURCE_NAME_KEY))) {
            metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, path.getFileName().toString());
        }
        metadata.set(Metadata.CONTENT_LENGTH, Long.toString(Files.size(path)));
        return new TikaInputStream(path);
    }
Creates a TikaInputStream from the file at the given path. The file name
and length are stored as input metadata in the given metadata instance.
<p>
If there's an {@link TikaCoreProperties#RESOURCE_NAME_KEY} in the
metadata object, this will not overwrite that value with the path's name.
<p>
Note that you must always explicitly close the returned stream to
prevent leaking open file handles.

@param path     input file
@param metadata metadata instance
@return a TikaInputStream instance
@throws IOException if an I/O error occurs
tika-core/src/main/java/org/apache/tika/io/TikaInputStream.java