How to extract the file upload content in SOA-P 5 using HttpGateway?
Issue
- Here is an
HttpGatewayESB action defined.
<services>
<service category="Vehicles" name="Cars" description="" invmScope="GLOBAL">
<listeners>
<http-gateway name="Http" urlPattern="esb-cars/*" payloadAs="BYTES"/>
</listeners>
<actions mep="RequestResponse">
<action name="HttpAction" class="org.jboss.soa.esb.samples.quickstart.httpgateway.MAction"/>
</actions>
</service>
</services>
This is working fine. It helps users to upload a file to the ESB action using the following HTML.
<form action="http://localhost:8080/Quickstart_http_gateway/http/esb-cars/hello"
enctype="multipart/form-data" method="post">
<p>Please specify a file, or a set of files:<br>
<input type="file" name="datafile" size="40">
</p>
<div><input type="submit" value="Send"></div>
</form>
The problem arises during extracting the file contents from the message during the following invocation.
byte[] content = (byte[])message.getBody().get();
It gives the following result.
-----------------------------1119622724132079857230587322
Content-Disposition: form-data; name="datafile"; filename="myfile"
Content-Type: application/octet-stream
This is a test file.
-----------------------------1119622724132079857230587322--
Is there a way to extract only the part of the http request that has the file contents?
Environment
- Red Hat JBoss SOA Platform (SOA-P)
- 5.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
