I want to implement a Restful service to upload a file. Following is what I have done so far. I can't get the file.
Service Interface
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/upload-ifc")
public boolean uploadIfcFile(Attachment file)
The implementation as follows
public boolean uploadIfcFile(Attachment attachment) throws IOException {
LOG.info("Uploding the ifcFile.....");
if (attachment != null) {
LOG.info("GOT___ATTACHMENT");
} else {
LOG.info("ATTACHMENT_NULL");
}
Object o = attachment.getObject();
if (o != null) {
LOG.info("GOT_OBJECT");
} else {
LOG.info("OBJECT_NULL");
}
File ifcFile = (File) o;
LOG.info("___________: " + ifcFile.getName());
return controller.uploadIfcFile(ifcFile);
}
OUTPUT is
Uploding the ifcFile.....
GOT___ATTACHMENT
OBJECT_NULL
I don't know how to get access the file here. I searched a lot but couldn't get a good resource. I am deploying this in wso2 application server and Jax rs implementation is Axis2 CXF.