<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Handling multiparts in Restful applications using CXF</title>
	<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/</link>
	<description>Life, Technology and More</description>
	<pubDate>Fri, 30 Jul 2010 10:37:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>

	<item>
		<title>By: brian</title>
		<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-4001</link>
		<author>brian</author>
		<pubDate>Wed, 14 Jul 2010 18:37:02 +0000</pubDate>
		<guid>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-4001</guid>
		<description>Thx! Not much documentation on multipart handling with REST clients in the books.</description>
		<content:encoded><![CDATA[<p>Thx! Not much documentation on multipart handling with REST clients in the books.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Saravanan Ramamoorthy</title>
		<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3995</link>
		<author>Saravanan Ramamoorthy</author>
		<pubDate>Thu, 20 May 2010 06:37:12 +0000</pubDate>
		<guid>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3995</guid>
		<description>Hi Arul,

I tried to send attachments from Jax-Rs.
I need all content - headers so I have used the Attachment class and passing DataHandler and MultiValuedMap parameters.
I set all the content headers in the MultiValuedMap.

I am able to get all content headers exception Content-Location.
The first attachment's Content-Location retrieves correctly but the subsequent Content-Location 's are changed to lower case(content-location) and the values are set to null.

Please suggest me.

Regards
Saravanan R</description>
		<content:encoded><![CDATA[<p>Hi Arul,</p>
<p>I tried to send attachments from Jax-Rs.<br />
I need all content - headers so I have used the Attachment class and passing DataHandler and MultiValuedMap parameters.<br />
I set all the content headers in the MultiValuedMap.</p>
<p>I am able to get all content headers exception Content-Location.<br />
The first attachment&#8217;s Content-Location retrieves correctly but the subsequent Content-Location &#8217;s are changed to lower case(content-location) and the values are set to null.</p>
<p>Please suggest me.</p>
<p>Regards<br />
Saravanan R</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arul</title>
		<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3973</link>
		<author>Arul</author>
		<pubDate>Wed, 16 Dec 2009 05:04:00 +0000</pubDate>
		<guid>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3973</guid>
		<description>Hi Shivakumar,

Here is an example from CXF system &lt;a href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java" rel="nofollow"&gt;tests&lt;/a&gt;:

    @POST
    @Path("/books/formimage")
    @Consumes("multipart/form-data")
    @Produces("multipart/form-data")
    public MultipartBody addBookFormImage(MultipartBody image) throws Exception {
        return image;
    }

Is this something you were looking for?

Cheers,
Arul</description>
		<content:encoded><![CDATA[<p>Hi Shivakumar,</p>
<p>Here is an example from CXF system <a href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java" rel="nofollow">tests</a>:</p>
<p>    @POST<br />
    @Path(&#8221;/books/formimage&#8221;)<br />
    @Consumes(&#8221;multipart/form-data&#8221;)<br />
    @Produces(&#8221;multipart/form-data&#8221;)<br />
    public MultipartBody addBookFormImage(MultipartBody image) throws Exception {<br />
        return image;<br />
    }</p>
<p>Is this something you were looking for?</p>
<p>Cheers,<br />
Arul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shivakumar</title>
		<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3972</link>
		<author>Shivakumar</author>
		<pubDate>Mon, 14 Dec 2009 06:55:35 +0000</pubDate>
		<guid>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3972</guid>
		<description>Please could add a example code for Multipart data as a Response .</description>
		<content:encoded><![CDATA[<p>Please could add a example code for Multipart data as a Response .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arul</title>
		<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3887</link>
		<author>Arul</author>
		<pubDate>Mon, 15 Jun 2009 04:52:43 +0000</pubDate>
		<guid>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3887</guid>
		<description>Hi Tom,

I believe you got a bug in your code. Change your code as shown below, and it should work:

InputStream in = dataHandler1.getInputStream();
while ((anInt = in.read()) != -1) {
  flOut.write(anInt);
}

HTH,
Arul</description>
		<content:encoded><![CDATA[<p>Hi Tom,</p>
<p>I believe you got a bug in your code. Change your code as shown below, and it should work:</p>
<p>InputStream in = dataHandler1.getInputStream();<br />
while ((anInt = in.read()) != -1) {<br />
  flOut.write(anInt);<br />
}</p>
<p>HTH,<br />
Arul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3884</link>
		<author>Tom</author>
		<pubDate>Mon, 08 Jun 2009 21:39:48 +0000</pubDate>
		<guid>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3884</guid>
		<description>Hello Arul,

If I use curl to upload an image to cxf, the image size keep growing.  Looks like it enter an infinite loop.

Any suggestions would be much appreciated.


        DataHandler dataHandler1 = attachments.get(0).getDataHandler();

try {
                //File outFl = new File("c:\\tmp\\" + imgName);
                File tmpFl = new File("/image/" + image.getF1Username());
                if (!tmpFl.exists()) {
                    tmpFl.mkdirs();
                }
                File outFl = new File("/image/" + image.getF1Username()+ "/" + image.getImageName());

                FileOutputStream flOut = new FileOutputStream(outFl);
                int anInt;
                while ((anInt = dataHandler1.getInputStream().read()) != -1) {
                    flOut.write(anInt);
                }

                flOut.flush();
                flOut.close();

                cir.setCount(1);
                cir.getItems().add(image);
                cir.setDetailIncluded(true);
                cir.setStatusCode(2000);
                cir.setStatusMessage("successfull");
            } catch (IOException ex) {
                DigLockLogger.record(Level.SEVERE, ImageServicesResource.class.getName() + ".postImage ",
                        StackTraceUtil.getStackTrace(ex));

                cir.setStatusCode(6000);
                cir.setStatusMessage("Failed to persist the contact image: "
                        + ex.getMessage());
            }</description>
		<content:encoded><![CDATA[<p>Hello Arul,</p>
<p>If I use curl to upload an image to cxf, the image size keep growing.  Looks like it enter an infinite loop.</p>
<p>Any suggestions would be much appreciated.</p>
<p>        DataHandler dataHandler1 = attachments.get(0).getDataHandler();</p>
<p>try {<br />
                //File outFl = new File(&#8221;c:\\tmp\\&#8221; + imgName);<br />
                File tmpFl = new File(&#8221;/image/&#8221; + image.getF1Username());<br />
                if (!tmpFl.exists()) {<br />
                    tmpFl.mkdirs();<br />
                }<br />
                File outFl = new File(&#8221;/image/&#8221; + image.getF1Username()+ &#8220;/&#8221; + image.getImageName());</p>
<p>                FileOutputStream flOut = new FileOutputStream(outFl);<br />
                int anInt;<br />
                while ((anInt = dataHandler1.getInputStream().read()) != -1) {<br />
                    flOut.write(anInt);<br />
                }</p>
<p>                flOut.flush();<br />
                flOut.close();</p>
<p>                cir.setCount(1);<br />
                cir.getItems().add(image);<br />
                cir.setDetailIncluded(true);<br />
                cir.setStatusCode(2000);<br />
                cir.setStatusMessage(&#8221;successfull&#8221;);<br />
            } catch (IOException ex) {<br />
                DigLockLogger.record(Level.SEVERE, ImageServicesResource.class.getName() + &#8220;.postImage &#8220;,<br />
                        StackTraceUtil.getStackTrace(ex));</p>
<p>                cir.setStatusCode(6000);<br />
                cir.setStatusMessage(&#8221;Failed to persist the contact image: &#8221;<br />
                        + ex.getMessage());<br />
            }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arul</title>
		<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3860</link>
		<author>Arul</author>
		<pubDate>Sat, 11 Apr 2009 23:38:32 +0000</pubDate>
		<guid>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3860</guid>
		<description>Hi Nickaj,

Thanks!

The sources are now attached to the blog entry.

-Arul</description>
		<content:encoded><![CDATA[<p>Hi Nickaj,</p>
<p>Thanks!</p>
<p>The sources are now attached to the blog entry.</p>
<p>-Arul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nickaj</title>
		<link>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3857</link>
		<author>Nickaj</author>
		<pubDate>Mon, 30 Mar 2009 11:29:54 +0000</pubDate>
		<guid>http://aruld.info/handling-multiparts-in-restful-applications-using-cxf/#comment-3857</guid>
		<description>good blog post ! Arul , it is very useful if you can  upload complete source codes for this somewhere..?</description>
		<content:encoded><![CDATA[<p>good blog post ! Arul , it is very useful if you can  upload complete source codes for this somewhere..?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
