Hi,

 

I would like to build a restlet based client but I need to post a
multipart form containing a file as well as parameters.  Is there som
way of doing this in the restlet api like using Part objects in a
PostMethod in HttpClient?

 

Thanks,

Joshua

 

 

 

From: Jerome Louvel <contact <at> noelios.com>
Subject: RE: File uploading
<http://news.gmane.org/find-root.php?message_id=%3c003101c6741a%2497ee5a
f0%240200a8c0%40colorado%3e> 
Newsgroups: gmane.comp.java.restlet
<http://news.gmane.org/gmane.comp.java.restlet> 
Date: 2006-05-10 10:14:56 GMT (1 year, 5 weeks, 8 hours and 45 minutes
ago)

 
Max,
 
> 1)if i must send only one file, client side, create an 
> FileRepresentation fr 
> and use call.setInput(fr) ... but server side how do i handle 
> the call? how do 
> i retrieve the file?  
 
Something like this will write your uploaded file to a local file:
File input = new File("...");
call.getInput().write(input.getOutputStream());
 
> 2)For example you think to send an id (parameter) and a file 
> pdf, how can i 
> do? (server side) how do i handle the call?
 
On the client:
call.setResourceRef("http://yourserver.com/aaa/bbb/upload?id=123);
 
On the server:
call.getResourceRef().getQueryAsForm()...
 
> then ...
> 
> 3)can i use directly the default constructor of RestletFileUpload? ==>
> RestletFileUpload rfu = new RestletFileUpload(); 
> Is there any problems?
 
Currently the support for multipart/form is only available from a
browser.
Otherwise, you can simply use the FileRepresentation by setting the
correct
file media type (GIF, JPEG, XML, etc.).
 
call.setInput(new FileRepresentation("...", MediaTypes.XXX));
 
Thx,
Jerome
 

 

Reply via email to