Surjendu,

By default, Restlet does not handle the multi-part form request, so you
will need to use some form of multi-part form handling library to do
this. The file upload library that is most commonly used, and the one
used by RestletFileUpload, is the Apache commons-fileupload library.
Make sure the commons-fileupload-1.2.jar file is in your classpath when
you run your application, and Restlet should be able to pick it up.

The RestletFileUpload is just an example of how to do it, you can take a
look at the code and break it down as you see fit.

Mitch

> -----Original Message-----
> From: news [mailto:[EMAIL PROTECTED] On Behalf Of Surjendu
> Sent: Wednesday, April 30, 2008 12:53 AM
> To: [email protected]
> Subject: Send and Parse Attachment using Restlet
> 
> Please help me regarding sending a file as an attachment 
> using Restlet. 
> I have
> written my client code. Please let me know if it's correct.
> 
> Client:
> 
> FileRepresentation rep = new
> FileRepresentation("c:\\input.text",MediaType.TEXT_ALL, 0);
> 
> Client client = new Client(Protocol.HTTP); Response response 
> = client.put("http://localhost:19090/cm/";, rep);
> 
> Server:
> 
> 
> What would i code in Server. I saw in the forum one 
> implementation of RestletFileUpload. Do I have to use 
> RestletFileUpload? 
> Aren't there any other way?
> 
> 
> DiskFileItemFactory factory = new DiskFileItemFactory(); 
> RestletFileUpload upload = new  RestletFileUpload(factory); try {
>      List items = upload.parseRequest(getRequest());
>      int i = 0;
>      for (final Iterator it = items.iterator(); it.hasNext(); ) 
> 
>      {    
>       FileItem fi = (FileItem)it.next();
>       File saveTo = new File("c:\\temp\\FileReqReceived" + i 
> + ".txt");
>       fi.write(saveTo);
>       i++;
>      }
> }catch(Exception e)
> 
> {
>   e.printstackTrace();
> }
> 
> I have also seen that I receive a multi-part error. 
> How to solve this?
> 
> Regards
> Surjendu
> 
> 

Reply via email to