You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Benson Margulies <bi...@gmail.com> on 2011/04/25 18:54:06 UTC

ordinary fields buried in attachments

I'm using multipart/form-data to include a file upload, but there are
some ordinary fields as well. Am I stuck with having them handled in
Java as Attachments, or is there some way to get them bound to string
params?

Re: ordinary fields buried in attachments

Posted by Benson Margulies <bi...@gmail.com>.
That helped. I'm in process.

On Mon, Apr 25, 2011 at 1:48 PM, Sergey Beryozkin <sb...@gmail.com> wrote:
> HI Benson
>
> On Mon, Apr 25, 2011 at 5:54 PM, Benson Margulies <bi...@gmail.com> wrote:
>> I'm using multipart/form-data to include a file upload, but there are
>> some ordinary fields as well. Am I stuck with having them handled in
>> Java as Attachments, or is there some way to get them bound to string
>> params?
>>
>
> If you can use @Multipart annotation then try something like this:
>
> public Response addFiles(@Multipart("owner") String name,
>                                 @Multipart("files") List<Book> books) {}
>
> alternatively, try having MultipartBody only in the signature and then do
>
> public Response addFiles(MultipartBody body) {
>    body.getAttachmentObject(contentId, String.class);
> }
>
> Note, only in CXF 2.3.4 Content-Disposition's 'name' parameter is also
>  checked for body.getAttachmentObject(contentId, SomeClass.class); to
> succeed, in earlier versions only Content-Id is checked
>
> Does it help ? If not then send me a sample payload please
>
> Cheers, Sergey
>

Re: ordinary fields buried in attachments

Posted by Sergey Beryozkin <sb...@gmail.com>.
HI Benson

On Mon, Apr 25, 2011 at 5:54 PM, Benson Margulies <bi...@gmail.com> wrote:
> I'm using multipart/form-data to include a file upload, but there are
> some ordinary fields as well. Am I stuck with having them handled in
> Java as Attachments, or is there some way to get them bound to string
> params?
>

If you can use @Multipart annotation then try something like this:

public Response addFiles(@Multipart("owner") String name,
                                 @Multipart("files") List<Book> books) {}

alternatively, try having MultipartBody only in the signature and then do

public Response addFiles(MultipartBody body) {
    body.getAttachmentObject(contentId, String.class);
}

Note, only in CXF 2.3.4 Content-Disposition's 'name' parameter is also
 checked for body.getAttachmentObject(contentId, SomeClass.class); to
succeed, in earlier versions only Content-Id is checked

Does it help ? If not then send me a sample payload please

Cheers, Sergey