2

我想实现一个 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);
    }

输出是

Uploding the ifcFile.....
GOT___ATTACHMENT
OBJECT_NULL

我不知道如何在此处访问该文件。我搜索了很多,但找不到好的资源。我在wso2 应用程序服务器中部署它,而 Jax rs 实现是 Axis2 CXF。

4

0 回答 0