...
Code Block | ||||
---|---|---|---|---|
| ||||
<route> <from uri="direct:start" /> <!-- using bean 'mongoBean' defined above --> <to uri="gridfs:mongoBean?database=${mongodb.database}&operation=findOne" /> <to uri="direct:result" /> </route> |
GridFS operations - producer
...
endpoint
count
Returns the total number of file in the collection, returning an Integer as the OUT message body.
...
Code Block |
---|
// from("direct:countlistAll").to("gridfs?database=tickets&operation=listAll"); Reader result = template.requestBodyAndHeader("direct:listAll", "irrelevantBody"); filename1.txt 1252314321 2016 filename2.txt 2897651254 2016/01/01:01. |
findOne
Finds a file in the GridFS system and sets the body to an InputStream of the content. Also provides the metadata has headers. It uses Exchange.FILE_NAME from the incoming headers to determine the file to find.
Code Block |
---|
// from("direct:findOne").to("gridfs?database=tickets&operation=findOne"); Map<String, Object> headers = new HashMap<String, Object>(); headers.put(Exchange.FILE_NAME, "filename.txt"); InputStream result 1252314321 2016 |
...
= template.requestBodyAndHeaders("direct:findOne", "irrelevantBody", headers);
|
create
Creates a new file in the GridFs database. It uses the Exchange.FILE_NAME from the incoming headers for the name and the body contents (as an InputStream) as the content.
Code Block |
---|
// from("direct:create").to("gridfs?database=tickets&operation=create");
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(Exchange.FILE_NAME, "filename.txt");
InputStream stream = ... the data for the file ...
template.requestBodyAndHeaders("direct:create", stream, headers);
|
GridFS Consumer
See also
...