You need to create a Rest service as described in my previous blog
@Path("upload/")
@Produces({"application/xml"})
@Component
@Scope("request")
public class Upload
{
@POST
//to tell that it will consume the multipart requests only
@Consumes("multipart/form-data")
public String uploadFile(
@Context HttpServletRequest request,
@FormParam("attachmentFile") FormDataContentDisposition dispostion,
@FormParam("attachmentFile") InputStream attachmentFile)
{
//file name can be retrieved from dispostion in the following manner
String fileName = dispostion.getFileName();
//file data can be read from the attachmentFile input stream
//returning the response xml which can be
// anything what you wanna show to your client
return "ok";
}
For client could be any html with a file tag
<form action="upload" enctype="multipart/form-data" method="POST">
//here we are giving the file name which will be
//used in service to access the file
<input type="file" name="attachmentFile" />
<input type="submit" value="submit" />
</form>
Thank you a lot!
It has been very interesting for me.
I will follow your blog.