Dynamic mapping for BeanIO in Camel on windows - apache-camel

I working on CSV to CSV file conversion using beanIO camel compnnet, is there any way or workaround to load mapping files on fly or at runtime in marshal /unmarshal endpoint in camel route.
Hard coding of files is working for me but not the with placeholder
.unmarshal(new BeanIODataFormat("file://C://Camel//Dev//mapping//unmarshlling//inputMapping.xml", "xyz"))
OR
.to("dataformat:beanio:unmarshal?mapping='file://C://Camel//Dev//mapping//unmarshlling//inputMapping.xml'?streamName=xyz")
is working but
.unmarshal(new BeanIODataFormat("{{file name}}", "xyz"))
OR
.to("dataformat:beanio:unmarshal?mapping=("{{file name}}"?streamName=xyz")
Is not working for me , I want to put mapping file as in put and which will load from external folder please help

Related

How can i save a file on react folder from a url

Hello guys i need to download files from my database or my Onedrive and save them into react, this files is for my 3d models and the types is obj and mtl. For can i load dinamyc objects from database i need this feature, how can i do this ? I'm using three.js in this project.
Today the project is loading the files stored in project but i like to find a away to pick this from a database or a storage provider.
I tried to do using fetch or something like else but i can't find a away to do this correctly. I don't now if three.js supports url files i try to find but i don't see anything can help me.
Unless three.js provides a feature to take input from memory (in which case you can simply download the file into memory and pass it to three.js), doing this solely from a react app isn't possible. You will need to host your website on a server to have dynamic access to the public directory serving the react website.
Standalone react builds have static assets and can't be updated without creating another build

Create csv file and pass It to backend call in React

I have a scenario where I want to create csv file and the same generated csv file I would like to pass It to backend call.
I can generate csv file using below plugin but would like to know how can I pass It to backend once file is generated?
https://www.npmjs.com/package/react-csv
Anyone please share the Idea on It?

Getting Filename without extension : camel

I have header with filename with extension like this
<setHeader>
<simple>Test.txt</simple>
</setHeader>
I need to fetch only filename ie. Test alone in another header. Can anyone help me to achieve this.
Thanks.
You have multiple options. The examples take the full filename from a header and write the filename without extension into another header.
You write a Java Bean to use full Java power (for example Apache Commons FilenameUtils.getBaseName) and call it from your route. See this Camel documentation how to inject header values into your bean methods. In the route you call the bean like this
.setHeader("filename", method(beanReference, "methodName"))
Or you add camel-groovy to your dependencies to get more scripting power than with Camel Simple. Then you can do it directly in the Camel route
setHeader("filename").groovy("request.headers.get('fullFilename')
.take(request.headers.get('fullFilename').lastIndexOf('.'))")

Uploading users data using CSV file with flow JS

I want to provide upload functionality to my angular JS application , I want to restrict user to upload only CSV/XSL files only,and the File size must be restricted to 100KB ,the users data from the file should be stored in the local storage of browser using Flow JS, I am new to Flow JS ,can anyone give me hint or code-snippet to implement this.I don't wanna use any backend only local storage to store my data
To restrict selectable files to CSV and XLS or XSLX, use FlowJS assignBrowse method :
.assignBrowse(domNodes, isDirectory, singleFile, attributes)
This way
flow.assignBrowse(element, false, false, {"accept": ".csv,.xls,.xlsx"});
Read official docs for more : https://github.com/flowjs/flow.js/#methods
Unfortunately, this is no limit for filesize.
But you'll find some useful information on this thread which could help :

Camel Sftp - Download Multiple Files

I am able to successfully download one/all files from a sftp directory using the following uri in canmel route definition
Download all files
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true"
Download one file
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true&fileName=one.txt"
My requirement is to download a specific list of files = one.text, two.text.
How can I pass list of fileNames to the Camel route? Preferablly I am looking for a solution where in I can specify something like the below
"sftp://userName#serverName/directoryName?knownHostsFile=./known_hosts&privateKeyFile=./id_rsa&proxy=#proxy&noop=true&fileName=one.txt,two.txt"
The Camel FTP component extends the File component and many of the options from file is also applicable for the FTP component, so read this page
http://camel.apache.org/file2
You can for example use include to specify a regular expression that matches the files you want. Or implement a custom filter class and use the filter option, etc.

Resources