Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Maven users will need to add the following dependency to their pom.xml for this component:

...

Make sure you read the section titled Default when consuming files further below for details related to consuming files.

...

URI format

...

...

Where share represents the share to connect to and dir is optionaly any underlying directory. Can contain nested folders.

...

The options below are exclusive for the JCIFS component.

...

...

Name

Default Value

Description

password

null

Mandatory Specifies the password to use to log in to the remote file system.

localWorkDirectory

null

When consuming, a local work directory can be used to store the remote file content directly in local files, to avoid loading the content into memory. This is beneficial, if you consume a very big remote file and thus can conserve memory. See below for more details.

...

See File for more options as all the options from File is inherited.

...

For example to set the localWorkDirectory to ''/tmp'' you can do:

...

You can have as many of these options as you like.

...

smb://foo@myserver.example.com/sharename?password=secret
smb://companydomain;foo@myserver.company.com/sharename?password=secret

...

...

This component is an extension of the File component. So there are more samples and details on the File component page.

...

Message Headers

The following message headers can be used to affect the behavior of the component

...

...

Header

Description

CamelFileName

Specifies the output file name (relative to the endpoint directory) to be used for the output message when sending to the endpoint. If this is not present and no expression either, then a generated message ID is used as the filename instead.

CamelFileNameProduced

The actual absolute filepath (path + name) for the output file that was written. This header is set by Camel and its purpose is providing end-users the name of the file that was written.

CamelFileBatchIndex

Current index out of total number of files being consumed in this batch.

CamelFileBatchSize

Total number of files being consumed in this batch.

CamelFileHost

The remote hostname.

CamelFileLocalWorkPath

Path to the local work file, if local work directory is used.

...

Using Local Work Directory

...

So if you want to download files from a remote server and store it as files then you need to route to a file endpoint such as:

...

...

The route above is ultra efficient as it avoids reading the entire file content into memory. It will download the remote file directly to a local file stream. The java.io.File handle is then used as the Exchange body. The file producer leverages this fact and can work directly on the work file java.io.File handle and perform a java.io.File.rename to the target filename. As Camel knows it's a local work file, it can optimize and use a rename instead of a file copy, as the work file is meant to be deleted anyway.

...

Samples

In the sample below we set up Camel to download all the reports from the SMB/CIFS server once every hour (60 min) and store it as files on the local file system.

...

...

And the route using Spring DSL:

...

...

Filter using org.apache.camel.component.file.GenericFileFilter

...

In the sample we have built our own filter that only accepts files starting with report in the filename.

...

And then we can configure our route using the filter attribute to reference our filter (using # notation) that we have defined in the spring XML file:

...

...

Filtering using ANT path matcher

...

The sample below demonstrates how to use it:

...

...