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