cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to automatically upload files from a folder?

Gerard_
Champ in-the-making
Champ in-the-making

I would to know if there is any way that nuxeo upload the files placed in a specific folder.

Thanks.

1 ACCEPTED ANSWER

bruce_Grant
Elite Collaborator
Elite Collaborator

You can write a custom listener that runs on a timed basis. The listener scans the directory and ingests the files it finds in the directory.

For example...

// events contribution - this one runs once a day, but it could run on any schedule you need (e.g. every 5 minutes)
		
	<schedule id="concena_directoryimport">
		<eventId>importFromDirectory</eventId>
		<eventCategory>default</eventCategory>
		<cronExpression>0 30 6 * * ?</cronExpression>
	</schedule>	

	// listener contribution
	
	<listener name="concena_directoryimportlistener" async="true" postCommit="false"
		class="com.concena.core.directoryimport.DirectoryImportListener" priority="165">
		<event>importFromDirectory</event>
	</listener>	
	
	// listener snippet
	
	protected void handleDirectoryImportEvent(Event event) {

		:

		// 2. collect up files in the template import directory
		// read through the specified directory and load file names into an array
		File directory = null;
		String[] files = null;
	
		directory = new File(getImportDirectory());
		files = directory.list(new ImportTemplateFileFilter());	// filter limits collection to Office Word and Excel templates
	
		: 
		
		// etc. - get a CoreSession, walk through the files, create documents from files, log results, etc.

View answer in original post

3 REPLIES 3

bruce_Grant
Elite Collaborator
Elite Collaborator

You can write a custom listener that runs on a timed basis. The listener scans the directory and ingests the files it finds in the directory.

For example...

// events contribution - this one runs once a day, but it could run on any schedule you need (e.g. every 5 minutes)
		
	<schedule id="concena_directoryimport">
		<eventId>importFromDirectory</eventId>
		<eventCategory>default</eventCategory>
		<cronExpression>0 30 6 * * ?</cronExpression>
	</schedule>	

	// listener contribution
	
	<listener name="concena_directoryimportlistener" async="true" postCommit="false"
		class="com.concena.core.directoryimport.DirectoryImportListener" priority="165">
		<event>importFromDirectory</event>
	</listener>	
	
	// listener snippet
	
	protected void handleDirectoryImportEvent(Event event) {

		:

		// 2. collect up files in the template import directory
		// read through the specified directory and load file names into an array
		File directory = null;
		String[] files = null;
	
		directory = new File(getImportDirectory());
		files = directory.list(new ImportTemplateFileFilter());	// filter limits collection to Office Word and Excel templates
	
		: 
		
		// etc. - get a CoreSession, walk through the files, create documents from files, log results, etc.

Gerard_
Champ in-the-making
Champ in-the-making

Thanks bruce, but I'm new in Nuxeo and I'm really lost. I will look at listeners documentation because I don't know where to start.

Vincent_Dutat
Confirmed Champ
Confirmed Champ

Hi,

Laurent Doguin from Nuxeo recently posted an article about it on the Nuxeo blog, here is a link to it : http://dev.blogs.nuxeo.com/2012/03/monday-dev-heaven-multithreaded-transactional-documents-import-nu...

Getting started

Attention: Blogs & Forums are in READ-ONLY mode from Oct 9-19 as we transition to our new platform. Learn more.

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.