protected OutputStream getOutputStream(OutputStreamFactory fsOSFactory, FileResource fileResource) {
        OutputStream os = null;
        try {
            os = fsOSFactory.getOutputStream(fileResource.getMetadata());
        } catch (IOException e) {
            //This can happen if the disk has run out of space,
            //or if there was a failure with mkdirs in fsOSFactory
            LOG.error("{}", getXMLifiedLogMsg(IO_OS, fileResource.getResourceId(), e));
            throw new BatchNoRestartError("IOException trying to open output stream for " + fileResource.getResourceId(), e);
        }
        return os;
    }
Use this for consistent logging of exceptions.  Clients must
check for whether the os is null, which is the signal
that the output file already exists and should be skipped.

@param fsOSFactory  factory that creates the outputstream
@param fileResource used by the OSFactory to create the stream
@return the OutputStream or null if the output file already exists
tika-batch/src/main/java/org/apache/tika/batch/fs/AbstractFSConsumer.java