我想实现Restful服务来上传文件。以下是我到目前为止所做的工作。我无法获取该文件。
服务接口
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Path("/upload-ifc")
public boolean uploadIfcFile(Attachment file)
实施如下
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
Uploding the ifcFile.....
GOT___ATTACHMENT
OBJECT_NULL
我不知道如何在这里访问该文件。我搜索了很多,但无法获得良好的资源。我在wso2 application server中部署它,Jax rs实现是Axis2 CXF。