I don't want to use the FileUpload extension and the HTML. I use the post
method to do the stuff. But i got the message below:
Unsupported Media Type (415) - The server is refusing to service the request
because the entity of the request is in a format not supported by the requested
resource for the requested method
My Resetlet version is J2EE 2.07.
And the code below is the post method and the client:
/********************************
@Post
public FileRepresentation receive(FileRepresentation file){
try {
file.write(new FileOutputStream(new
File("/tmp/myfile.txt")));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return file;
}
*********************************/
the client:
/**********************************
ClientResource cr = new
ClientResource("http://211.71.75.133:8182/testFileUpload");
File file = new File("/var/temp/file.txt");
FileRepresentation fileEntity = new FileRepresentation(file,
MediaType.TEXT_PLAIN);
Form fileForm = new Form();
fileForm.add(Disposition.NAME_FILENAME,file.getName());
Disposition disposition = new Disposition(Disposition.TYPE_INLINE,
fileForm);
fileEntity.setDisposition(disposition);
try{
cr.post(fileEntity);
// resource.receive(fileEntity);
}
catch(Exception e){
System.out.print("dd");
e.printStackTrace();
}
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2682066