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

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

Thanks.

0 votes

2 answers

370 views

ANSWER



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.
2 votes



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.
03/23/2012


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-nuxeo.html

3 votes