Package org.apache.tika.pipes.emitter.fs
Class FileSystemEmitter
java.lang.Object
org.apache.tika.pipes.emitter.AbstractEmitter
org.apache.tika.pipes.emitter.fs.FileSystemEmitter
- All Implemented Interfaces:
Emitter
,StreamEmitter
Emitter to write to a file system.
This calculates the path to write to based on the basePath
and the value of the TikaCoreProperties.SOURCE_PATH
value.
<properties> <emitters> <emitter class="org.apache.tika.pipes.emitter.fs.FileSystemEmitter> <params> <!-- required --> <param name="name" type="string">fs</param> <!-- required --> <param name="basePath" type="string">/path/to/output</param> <!-- optional; default is 'json' --> <param name="fileExtension" type="string">json</param> <!-- optional; if the file already exists, options ('skip', 'replace', 'exception') default is 'exception' --> <param name="onExists" type="string">skip</param> <!-- optional; whether or not to pretty print the output default is false --> <param name="prettyPrint" type="boolean">true</param> </params> </emitter> </emitters> </properties>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
emit
(String path, InputStream inputStream, Metadata userMetadata, ParseContext parseContext) void
emit
(String emitKey, List<Metadata> metadataList, ParseContext parseContext) void
setBasePath
(String basePath) void
setFileExtension
(String fileExtension) If you want to customize the output file's file extension.void
setOnExists
(String onExists) What to do if the target file already exists.void
setPrettyPrint
(boolean prettyPrint) Methods inherited from class org.apache.tika.pipes.emitter.AbstractEmitter
emit, getName, setName
-
Constructor Details
-
FileSystemEmitter
public FileSystemEmitter()
-
-
Method Details
-
emit
public void emit(String emitKey, List<Metadata> metadataList, ParseContext parseContext) throws IOException, TikaEmitterException - Specified by:
emit
in interfaceEmitter
- Throws:
IOException
TikaEmitterException
-
setBasePath
-
setFileExtension
If you want to customize the output file's file extension. Do not include the "."- Parameters:
fileExtension
-
-
setOnExists
What to do if the target file already exists. NOTE: if more than one thread is trying write to the same file andFileSystemEmitter.ON_EXISTS.REPLACE
is chosen, you still might get aFileAlreadyExistsException
.- Parameters:
onExists
-
-
setPrettyPrint
-
emit
public void emit(String path, InputStream inputStream, Metadata userMetadata, ParseContext parseContext) throws IOException, TikaEmitterException - Specified by:
emit
in interfaceStreamEmitter
- Throws:
IOException
TikaEmitterException
-