cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r1031041 - in /websites/production/cxf/content: cache/docs.pageCache docs/jax-rs-multiparts.html
Date Mon, 11 Jun 2018 09:57:36 GMT
Author: buildbot
Date: Mon Jun 11 09:57:36 2018
New Revision: 1031041

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/jax-rs-multiparts.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/jax-rs-multiparts.html
==============================================================================
--- websites/production/cxf/content/docs/jax-rs-multiparts.html (original)
+++ websites/production/cxf/content/docs/jax-rs-multiparts.html Mon Jun 11 09:57:36 2018
@@ -117,22 +117,22 @@ Apache CXF -- JAX-RS Multiparts
          <td height="100%">
            <!-- Content -->
            <div class="wiki-content">
-<div id="ConfluenceContent"><p><span style="font-size:2em;font-weight:bold">JAX-RS
: Support for Multiparts</span>
+<div id="ConfluenceContent"><p><br clear="none"><span style="font-size:2em;font-weight:bold">JAX-RS
: Support for Multiparts</span>
 
 
-&#160;</p><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1524513378305 {padding: 0px;}
-div.rbtoc1524513378305 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1524513378305 li {margin-left: 0px;padding-left: 0px;}
+&#160;</p><p><br clear="none"></p><p><style type="text/css">/*<![CDATA[*/
+div.rbtoc1528711018536 {padding: 0px;}
+div.rbtoc1528711018536 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1528711018536 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1524513378305">
+/*]]>*/</style></p><div class="toc-macro rbtoc1528711018536">
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSMultiparts-Readingattachments">Reading
attachments</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSMultiparts-MultipartannotationandOptionalattachments">Multipart
annotation and Optional attachments</a></li></ul>
 </li><li><a shape="rect" href="#JAX-RSMultiparts-Writingattachments">Writing
attachments</a></li><li><a shape="rect" href="#JAX-RSMultiparts-UploadingfileswithClientAPI">Uploading
files with Client API</a></li><li><a shape="rect" href="#JAX-RSMultiparts-Readinglargeattachments">Reading
large attachments</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSMultiparts-Formsandmultiparts">Forms
and multiparts</a></li><li><a shape="rect" href="#JAX-RSMultiparts-Content-DispositionUTF-8filenames">Content-Disposition
UTF-8 file names</a></li></ul>
 </li><li><a shape="rect" href="#JAX-RSMultiparts-XOPsupport">XOP support</a></li><li><a
shape="rect" href="#JAX-RSMultiparts-MultipartFilters">Multipart Filters</a></li><li><a
shape="rect" href="#JAX-RSMultiparts-SigningMultiparts">Signing Multiparts</a></li><li><a
shape="rect" href="#JAX-RSMultiparts-NoteaboutStruts">Note about Struts</a></li></ul>
 </div><h1 id="JAX-RSMultiparts-Readingattachments">Reading attachments</h1><p>Individual
parts can be mapped to StreamSource, InputStream, DataSource or custom Java types for which
message body readers are available.</p><p>For example:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 @Path("/books/jaxbjson")
 @Produces("text/xml")
 public Response addBookJaxbJson(
@@ -142,19 +142,19 @@ public Response addBookJaxbJson(
 }
 </pre>
 </div></div><p>Note that in this example it's expected that the root part
named 'rootPart' is a text-xml Book representation, while a part named 'book2' is a Book JSON
sequence.</p><p>All attachment parts can be accessed as a list of <a shape="rect"
class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java">Attachment</a>
with Attachment making it easy to deal with a given part:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 public void addAttachments(List&lt;Attachment&gt; atts) throws Exception {
 }
 </pre>
 </div></div><p>For example, Attachment class can be used to get to a <a
shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/ContentDisposition.java">Content-Disposition</a>
header, when dealing with the form submission of files.</p><p>Similarly, the whole
request body can be represented as a <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartBody.java">MultipartBody</a>:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 public void addAttachments(MultipartBody body) throws Exception {
 body.getAllAtachments();
 body.getRootAttachment();
 }
 </pre>
 </div></div><p>When handling complex multipart/form-data submissions (such
as those containing files) MultipartBody (and Attachment) need to be used directly. In simpler
cases, when every form part can be captured by a String, the following code will suffice:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 @Consumes("multipart/form-data")
 public void addForm1(@FormParam("name") String title, @FormParam("id") Long id) throws Exception
{
 }
@@ -170,7 +170,7 @@ public void addForm3(MultivaluedMap&lt;S
 }
 </pre>
 </div></div><p>When working with either List of Attachments or MultipartBody,
one may want to process the individual parts with the help of some custom procedures. Starting
from CXF 2.3.0 it is also possible to do the following:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 public void addAttachments(MultipartBody body) throws Exception {
     Book book = body.getAttachmentObject("bookPart", Book.class);
 }
@@ -184,7 +184,7 @@ public void addAttachments(List&lt;Attac
 
 </pre>
 </div></div><p>When a user code has <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java">MessageContext</a>
injected, <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java">AttachmentUtils</a>
can also be used by the application code.</p><p>Please see these <a shape="rect"
class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java">test
resource class</a> and <a shape="rect" class="external-link" href="http://sberyozkin.blogspot.com/2009/02/multiparts-in-cxf-jaxrs.html"
rel="nofollow">blog entry</a> for more examples.</p><h2 id="JAX-RSMultiparts-MultipartannotationandOptionalattachments">Multipart
annotation and Optional attachments</h2><p>When you write the code lik
 e this</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 @Path("/books/jaxbjson")
 @Produces("text/xml")
 public Response addBookJaxbJson(
@@ -192,7 +192,7 @@ public Response addBookJaxbJson(
         @Multipart("book2") Book b2)  {}
 </pre>
 </div></div><p>the runtime will return a 400 status if either "rootPart"
or "book2" parts can not be found in the multipart payload.<br clear="none"> Starting
from 2.5.1 it is possible to request the runtime to report a null value in case of missing
parts:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 @Path("/books/jaxbjson")
 @Produces("text/xml")
 public Response addBookJaxbJson(
@@ -200,7 +200,7 @@ public Response addBookJaxbJson(
         @Multipart(value = "book2", required = false) Book b2) {}
 </pre>
 </div></div><p>The above code requires the "rootPart" part be available
and can handle the case where the "book2" part is missing.</p><h1 id="JAX-RSMultiparts-Writingattachments">Writing
attachments</h1><p>Starting from 2.2.4 it is also possible to write attachments
to the output stream, both on the client and server sides.</p><p>On the server
side it is sufficient to update the @Produces value for a given method:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public
class Resource {
+<pre class="brush: java; gutter: false; theme: Default">public class Resource {
    private List&lt;Book&gt; books; 
    @Produces("multipart/mixed;type=text/xml")
    public List&lt;Book&gt; getBooksAsMultipart() {
@@ -214,7 +214,7 @@ public Response addBookJaxbJson(
 }
 </pre>
 </div></div><p>Note that a 'type' parameter of the 'multipart/mixed' media
type indicates that all parts in the multiparts response should have a Content-Type header
set to 'text/xml' for both getBooksAsMultipart() and getBookAsMultipart() method responses.
The getBooksAsMultipart() response will have 3 parts, the first part will have its Content-ID
header set to "root.message@cxf.apache.org", the next parts will have '1' and '2' ids. The
getBookAsMultipart() response will have a single part only with its Content-ID header set
to "root.message@cxf.apache.org".</p><p>When returning mixed multiparts containing
objects of different types, you can either return a Map with the media type string value to
Object pairs or MultipartBody:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public
class Resource {
+<pre class="brush: java; gutter: false; theme: Default">public class Resource {
    private List&lt;Book&gt; books; 
    @Produces("multipart/mixed")
    public Map&lt;String, Object&gt; getBooks() {
@@ -236,7 +236,7 @@ public Response addBookJaxbJson(
 }
 </pre>
 </div></div><p>Similarly to the method returning a list in a previous code
fragment, getBooks() will have the response serialized as multiparts, where the first part
will have its Content-ID header set to "root.message@cxf.apache.org", the next parts will
have ids like '1', '2', etc.</p><p>In getBooks2() one can control the content
ids of individual parts.</p><p>You can also control the contentId and the media
type of the root attachment by using a Multipart annotation:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public
class Resource {
+<pre class="brush: java; gutter: false; theme: Default">public class Resource {
    @Produces("multipart/form-data")
    @Multipart(value = "root", type = "application/octet-stream") 
    public File testGetImageFromForm() {
@@ -245,7 +245,7 @@ public Response addBookJaxbJson(
 }
 </pre>
 </div></div><p>One can also have lists or maps of DataHandler, DataSource,
Attachment, byte arrays or InputStreams handled as multiparts.</p><p>On the client
side multiparts can be written the same way. For example:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">WebClient
client = WebClient.create("http://books");
+<pre class="brush: java; gutter: false; theme: Default">WebClient client = WebClient.create("http://books");
 client.type("multipart/mixed").accept("multipart/mixed");
 List&lt;Attachment&gt; atts = new LinkedList&lt;Attachment&gt;();
 atts.add(new Attachment("root", "application/json", new JSONBook()));
@@ -253,7 +253,7 @@ atts.add(new Attachment("image", "applic
 List&lt;Attachment&gt; atts = client.postAndGetCollection(atts, Attachment.class);
 </pre>
 </div></div><p>Note a new WebClient.postAndGetCollection which can be used
for a type-safe retrieval of collections. A similar WebClient.getCollection has also been
added.</p><p>When using proxies, a Multipart annotation attached to a method parameter
can also be used to set the root contentId and media type. Proxies do not support at the moment
multiple method parameters annotated with Multipart (as opposed to the server side) but only
a single multipart parameter:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public
class Resource {
+<pre class="brush: java; gutter: false; theme: Default">public class Resource {
     @Produces("multipart/mixed")
     @Consumes("multipart/form-data")
     @Multipart(value = "root", type = "application/octet-stream") 
@@ -261,7 +261,7 @@ List&lt;Attachment&gt; atts = client.pos
 }
 </pre>
 </div></div><p>A method-level Multipart annotation will affect the writing
on the server side and the reading on the client side. A parameter-level Multipart annotation
will affect writing on the client (proxy) side and reading on the server side. You don't have
to use Multipart annotations.</p><h1 id="JAX-RSMultiparts-UploadingfileswithClientAPI">Uploading
files with Client API</h1><p>At the moment the only way to upload a file is to
use a MultipartBody, Attachment or File:</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">WebClient
client = WebClient.create("http://books");t
+<pre class="brush: java; gutter: false; theme: Default">WebClient client = WebClient.create("http://books");
 client.type("multipart/form-data");
 ContentDisposition cd = new ContentDisposition("attachment;filename=image.jpg");
 Attachment att = new Attachment("root", imageInputStream, cd);
@@ -275,7 +275,7 @@ client.post(getClass().getResource("imag
 
 </pre>
 </div></div><p>Using File provides a simpler way as the runtime can figure
out how to create a ContentDisposition from a File.</p><h1 id="JAX-RSMultiparts-Readinglargeattachments">Reading
large attachments</h1><p>One can use the following properties to set up folder,
memory threshold and max size (from CXF 2.4.4 and 2.5) values when dealing with large attachments:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;beans&gt;
+<pre class="brush: java; gutter: false; theme: Default">&lt;beans&gt;
   &lt;jaxrs:server id="bookstore1"&gt;
      &lt;jaxrs:properties&gt;
          &lt;entry key="attachment-directory" value="/temp/bookstore1"/&gt;
@@ -288,20 +288,20 @@ client.post(getClass().getResource("imag
 &lt;/beans&gt;
 </pre>
 </div></div><p>Note that such properties can be set up on a per-endpoint
basis. Alternatively you can set "attachmentDirectory", "attachmentThreshold" and "attachmentMaxSize"
properties directly on either org.apache.cxf.jaxrs.provider.MultipartProvider or, when dealing
with multipart/form-data payloads, org.apache.cxf.jaxrs.provider.FormEncodingProvider.</p><p>Alternatively,
you might want to set the following system properties which will apply to all endpoints:</p><p>&gt;
-Dorg.apache.cxf.io.CachedOutputStream.Threshold=102400 <br clear="none"> and<br
clear="none"> &gt; -Dorg.apache.cxf.io.CachedOutputStream.OutputDirectory=/temp</p><p>Starting
from CXF 2.5.0 and 2.4.4:<br clear="none"> &gt; -Dorg.apache.cxf.io.CachedOutputStream.MaxSize=10000000</p><p>Note
that if a given attachment exceeds the maximum size property (default is no-limit) then HTTP
413 status will be returned. For more information on these configuration properties, please
see the documentation on <a shape="rect" hr
 ef="securing-cxf-services.html">Securing CXF Services</a>.</p><h2 id="JAX-RSMultiparts-Formsandmultiparts">Forms
and multiparts</h2><p>The <a shape="rect" class="external-link" href="http://www.w3.org/TR/html401/interact/forms.html"
rel="nofollow">Forms in HTML documents</a> recommendation <a shape="rect" class="external-link"
href="http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.2" rel="nofollow">suggests</a>
that multipart/form-data requests should mainly be used to upload files.</p><p>As
mentioned in the previous section, one way to deal with multipart/form-data submissions is
to deal directly with a CXF JAXRS Attachment class and get a Content-Disposition header and/or
the underlying input stream.</p><p>It is now possible (since 2.2.5) to have individual
multipart/form-data parts read by registered JAX-RS MessageBodyReaders, something that is
already possible to do for types like multipart/mixed or multipart/related.</p><p>For
example this <a shape="rect" class="exter
 nal-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJson">request</a>
can be handled by a method with the following signature:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 @Path("/books/jsonform")
 @Consumes("multipart/form-data")
 public Response addBookJsonFromForm(Book b1)  {...}
 </pre>
 </div></div><p>Similarly, this <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonJaxb">request</a>
can be handled by a method with the following signature:</p><div class="code panel
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+<pre class="brush: java; gutter: false; theme: Default">@POST
 @Path("/books/jsonjaxbform")
 @Consumes("multipart/form-data")
 public Response addBookJaxbJsonForm(@Multipart("jsonPart") Book b1,
                                         @Multipart("jaxbPart") Book b2) {}
 </pre>
-</div></div><p>Note that once a request has more than two parts then one
needs to start using @Mutipart, the values can refer to either ContentId header or to ContentDisposition/name.
Note that at the moment using @Multipart is preferred to using @FormParam unless a plain name/value
submission is dealt with. The reason is that @Multipart can also specify an expected media
type of the individual part and thus act similarly to a @Consume annotation.</p><p>When
dealing with multiple parts one can avoid using @Multipart and just use List, ex, List\&lt;Atachment\&gt;,
List\&lt;Book\&gt;, etc.</p><p>Finally, multipart/form-data requests with
multiple files (file uploads) can be supported too. For example, this <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles">request</a>
can be handled by a method with the signature like :</p><div class="code panel pdl"
style="b
 order-width: 1px;"><div class="codeContent panelContent pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@POST
+</div></div><p>Note that once a request has more than two parts then one
needs to start using @Multipart, the values can refer to either ContentId header or to ContentDisposition/name.
Note that at the moment using @Multipart is preferred to using @FormParam unless a plain name/value
submission is dealt with. The reason is that @Multipart can also specify an expected media
type of the individual part and thus act similarly to a @Consume annotation.</p><p>When
dealing with multiple parts one can avoid using @Multipart and just use List, ex, List\&lt;Atachment\&gt;,
List\&lt;Book\&gt;, etc.</p><p>Finally, multipart/form-data requests with
multiple files (file uploads) can be supported too. For example, this <a shape="rect" class="external-link"
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/attachmentFormJsonFiles">request</a>
can be handled by a method with the signature like :</p><div class="code panel pdl"
style="
 border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default">@POST
 @Path("/books/filesform")
 @Produces("text/xml")
 @Consumes("multipart/form-data")
@@ -309,7 +309,7 @@ public Response addBookFilesForm(@Multip
                                  @Multipart("files") List&lt;Book&gt; books) {} 
 </pre>
 </div></div><p>If you need to know the names of the individual file parts
embedded in a "files" outer part (such as "book1" and "book2"), then please use List&lt;Attachment&gt;
instead. It is currently not possible to use a Multipart annotation to refer to such inner
parts but you can easily get the names from the individual Attachment instances representing
these inner parts.</p><p>Note that it is only the last request which has been
structured according to the recommendation on how to upload multiple files but it is more
complex than the other simpler requests linked to in this section.</p><p>Please
note that using JAX-RS FormParams is recommended for dealing with plain application/www-url-encoded
submissions consisting of name/value pairs only.</p><h2 id="JAX-RSMultiparts-Content-DispositionUTF-8filenames">Content-Disposition
UTF-8 file names</h2><p>Starting from CXF 3.0.4 it is possible to specify a Content-Disposition
file names in a UTF-8 format, using a "filename*" Content-Di
 sposition extension parameter as opposed to the "filename" one.</p><p>Please
see <a shape="rect" class="external-link" href="https://tools.ietf.org/html/rfc6266" rel="nofollow">RFC
6266</a> and <a shape="rect" class="external-link" href="https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=core/src/test/java/org/apache/cxf/attachment/AttachmentUtilTest.java;h=6eeedd42e965f4df8390ee6077222b34e1520732;hb=HEAD">this
unit test</a> for more information.&#160;</p><h1 id="JAX-RSMultiparts-XOPsupport">XOP
support</h1><p>CXF JAXRS clients and endpoints can support <a shape="rect"
class="external-link" href="http://www.w3.org/TR/xop10/" rel="nofollow">XML-binary Optimized
Packaging (XOP)</a>.<br clear="none"> What it means at a practical level is that
a JAXB bean containing binary data is serialized using a multipart packaging, with the root
part containing non-binary data only but also linking to co-located parts containing the actual
binary payloads. Next it is deserialized into a JAX
 B bean on the server side.</p><p>If you'd like to experiment with XOP then you
need to set an "mtom-enabled" property on CXF jaxrs endpoints and clients.<br clear="none">
Please see <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java">JAXRSMultipartTest</a>
(testXopWebClient) and <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java">MultipartStore</a>
(addBookXop) for more details.</p><h1 id="JAX-RSMultiparts-MultipartFilters">Multipart
Filters</h1><p>&#160;</p><p>It is possible to intercept the attachment
write or read process starting from CXF 3.1.12.</p><p><a shape="rect" class="external-link"
href="https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartInputFilter.java"
rel="nofollow">Multipart
 InputFilter</a> and <a shape="rect" class="external-link" href="https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartOutputFilter.java"
rel="nofollow">MultipartOutputFilter</a> have been introduced. These filters can
be used to modify the list of the attachment parts or customize some of the individual part's
properties, example, replace the part input stream, etc.</p><p>These filters can
be registered from JAX-RS 2.0 client or container request/response filters or CXF in/out interceptors.
<a shape="rect" class="external-link" href="https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartInputFilter.java"
rel="nofollow">MultipartInputFilter</a> <a shape="rect" class="external-link"
href="https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java#L71"
rel="nofollow">can be added</a> to t
 he list of the input filters which is identified by a "multipart.input.filters" property
on the current CXF message. Likewise,&#160;<a shape="rect" class="external-link" href="https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/MultipartOutputFilter.java"
rel="nofollow">MultipartOutputFilter</a> <a shape="rect" class="external-link"
href="https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java#L61"
rel="nofollow">can be added</a> to the list of the output filters which is identified
by a "multipart.output.filters" property on the current CXF message.</p><h1 id="JAX-RSMultiparts-SigningMultiparts">Signing
Multiparts</h1><p>See <a shape="rect" href="http://cxf.apache.org/docs/jax-rs-jose.html#JAX-RSJOSE-SigningandVerificationofHTTPAttachments">this
section</a> for more information.</p><h1 id="JAX-RSMultiparts-NoteaboutStruts">Note
about Struts</h1><p>If 
 you are using CXF and <a shape="rect" class="external-link" href="http://struts.apache.org/2.2.1/index.html">Struts2</a>
within the same application and expecting CXF to process multipart/form-data payloads then
you need to make sure Struts2 dispatcher is not consuming the request input stream.</p><p>One
option is to let Struts2 handle URIs matching some specific patterns only, for example:</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
-<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">&lt;web-app&gt;
+<pre class="brush: java; gutter: false; theme: Default">&lt;web-app&gt;
 &lt;filter&gt;
       &lt;filter-name&gt;struts2&lt;/filter-name&gt;
       &lt;filter-class&gt;



Mime
View raw message