People were having trouble with DataSource.  I don't remember if the 
problem was fixed.  Instead of Datasource, try using InputStream or some 
other media type for the part.

Also, there is a 
@org.jboss.resteasy.annotations.providers.multipart.PartType annotation 
that is used to specify the Content-Type of the marshalled Multipart 
map, I don't have an annotation to specify the content-disposition.



On 7/6/11 6:49 AM, ujay68 wrote:
> Still trying to get multipart/form-data upload to work with a Resteasy
> client ...
>
> After some experimenting, I now found out that you can add an
> @PartType annotation to the client's Map parameter, like this:
>
> @POST
> @Consumes(MediaType.MULTIPART_FORM_DATA)
> @Produces(MediaType.APPLICATION_JSON)
> @Path("wherever")
> Object doUpload(@PartType(MediaType.APPLICATION_OCTET_STREAM)
> Map<String, DataSource>  parts);
>
> And then use this as:
>
> Map<String, DataSource>  parts = new HashMap<String, DataSource>();
> parts.put("file", new FileDataSource(new File("mypic.jpg")));
> Object response = client.doUpload(parts);
>
> Resteasy will then use
> org.jboss.resteasy.plugins.providers.multipart.MapMultipartFormDataWriter.
>
> That way, however, two important things are missing from the HTTP
> request (compared to a direct upload from a browser): the Content-Type
> is hard-wired to application/octet-stream because of the annotation
> and the mime part containing the file data does not have a
> Content-Disposition header with a "filename" parameter with the
> DataSource's name (in this example, this should be
> Content-Disposition: attachment; filename="mypic.jpg").
>
> Might this get fixed or do you suggest coding the upload with a
> hand-crafted request?
>
> Jay
>
>
>> Hi,
>>
>> how do I parameterize an interface method for a POST call that
>> consumes a multipart/form-data, for use with use
>> org.jboss.resteasy.client.ProxyFactory?
>>
>> The server implements something like this:
>>
>> @POST
>> @Consumes(MediaType.MULTIPART_FORM_DATA)
>> @Produces(MediaType.APPLICATION_JSON)
>> @Path("wherever")
>> public Response doFooImpl(MultipartFormDataInput object) {
>> List<InputPart>  items = object.getFormDataMap().get("ITEM"); /* ... */
>>   }
>>
>> In the client, I tried this:
>>
>> @POST
>> @Consumes(MediaType.MULTIPART_FORM_DATA)
>> @Produces(MediaType.APPLICATION_JSON)
>> @Path("wherever")
>> Object doFoo(Map<String, DataSource>  parts);
>>
>> But when I run this, the client throws a
>>
>> java.lang.RuntimeException: could not find writer for content-type
>> multipart/form-data type: java.util.Map
>>
>> Would it be better to use a javax.mail.Multipart as a client-side
>> parameter? Or 
>> org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInputImpl
>> (if that is an "official" API class)?
>>
>> Thanks, Jay
>>
>
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> Resteasy-users mailing list
> Resteasy-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/resteasy-users

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to