Camel Dropbox component
Available as of Camel x.xx
The dropbox: component allows you to treat Dropbox remote folders as a producer or consumer of messages. Using the Dropbox Java Core API (reference version for this component is 1.7.x), this camel component has the following features:
- As a consumer, download files and search files by queries
- As a producer, download files, move files between remote directories, delete files/dir, upload files and search files by queries
Maven users will need to add the following dependency to their pom.xml
for this component:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-dropbox</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency>
URI format
dropbox://[operation]?[options]
Where operation is the specific action (typically is a CRUD action) to perform on Dropbox remote folder.
Operation
Operation |
Description |
---|---|
|
deletes files or directories on Dropbox |
|
download files from Dropbox |
|
move files from folders on Dropbox |
|
upload files on Dropbox |
|
search files on Dropbox based on string queries |
Operations require additional options to work, some are mandatory for the specific operation.
Options
In order to work with Dropbox API you need to obtain an accessToken and a clientIdentifier
You can refer to the Dropbox documentation that expalins how to get them
Below are listed the mandatory options for all operations:
Property |
Mandatory |
Description |
---|---|---|
|
|
The access token to make API requests for a specific Dropbox user |
|
|
Name of the app registered to make API requests |
Headers
The following headers are set on exchanges during message transport.
Property |
Value |
---|---|
|
the database the message came from |
|
the couchdb changeset sequence number of the update / delete message |
|
the couchdb document id |
|
the couchdb document revision |
|
the method (delete / update) |
Headers are set by the consumer once the message is received. The producer will also set the headers for downstream processors once the insert/update has taken place. Any headers set prior to the producer are ignored. That means for example, if you set CouchDbId as a header, it will not be used as the id for insertion, the id of the document will still be used.
Message Body
The component will use the message body as the document to be inserted. If the body is an instance of String, then it will be marshalled into a GSON object before insert. This means that the string must be valid JSON or the insert / update will fail. If the body is an instance of a com.google.gson.JsonElement then it will be inserted as is. Otherwise the producer will throw an exception of unsupported body type.
Samples
For example if you wish to consume all inserts, updates and deletes from a CouchDB instance running locally, on port 9999 then you could use the following:
from("couchdb:http://localhost:9999").process(someProcessor);
If you were only interested in deletes, then you could use the following
from("couchdb:http://localhost:9999?updates=false").process(someProcessor);
If you wanted to insert a message as a document, then the body of the exchange is used
from("someProducingEndpoint").process(someProcessor).to("couchdb:http://localhost:9999")