data file upload with Camel

I'm trying to setup an Apache Camel route in a Java application where the consumer endpoint is a restlet component that handles an HTTP file upload as a POST of multipart form data and then the producer endpoint forwards the request to a rest service that also accepts multipart form data. I'm new to Camel and can't quite figure out how to wire it up properly. Below is how my route looks so far. Do I need to do any conversion on the body or will the multipart form data be forwarded as is? Can someone provide me some guidance on the proper way to do this or point me to the correct documentation?

    <route id="createentityattachment">
        <from uri="restlet:/EntityAttachments?restletMethod=POST&amp;restletBinding=#queryStringToHeadersRestletBinding"/>

        <camel:recipientList>
            <camel:simple>
                ${header.apigateway}/entityattachments/1.0.0.0/api/v1/EntityAttachments
            </camel:simple>
        </camel:recipientList>
    </route>

I was able to get this working with the below route definition. Note the streamCache="true" attribute on the route. This setting is required for the InputStream to be properly handled in the Exchange. See the Camel docs for more information.

<route id="createentityattachment" streamCache="true">
        <from uri="restlet:/EntityAttachments?restletMethod=POST&amp;restletBinding=#queryStringToHeadersRestletBinding"/>
        <removeHeaders excludePattern="X-eviCore-EntityAttachments*" pattern="^(Camel|Backbase|User-|Accept|Cache|Cookie|breadcrumbId|Host|Connection|DNT|Upgrade-Insecure-Requests|org.restlet.startTime).*$"/>
        <setHeader headerName="CamelHttpMethod">
            <constant>POST</constant>
        </setHeader>
        <to uri="http4://api.innovate.lan:8280/entityattachments/1.0.0.0/api/v1/EntityAttachments"/>
</route>
链接地址: http://www.djcxy.com/p/22194.html

上一篇: 是什么 '

下一篇: 用Camel上传数据文件