实现这一点的最佳方法是什么:
我的应用程序允许用户上传图像,这是通过 RESTful 服务完成的,编码为“multipart/form-data”。
现在,在服务的主体中,我真的不需要保存这个文件,但我想用它来传递和调用另一个服务。那么我是否可以使用 Jersey 客户端 API 进行另一个调用,而不必将文件保存到磁盘,然后传入所谓的“临时”文件。
这是我的一些代码:
@Path("/file")
public class UploadFileService {
    @POST
    @Path("/upload")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    public Response uploadFile(
        @FormDataParam("file") InputStream uploadedInputStream,
        @FormDataParam("file") FormDataContentDisposition fileDetail) {
            //Given that I have ‘uploadedInputStream’ can I just pass this  
            //directly into the second call, below?
            ClientConfig config = new DefaultClientConfig();
            Client client = Client.create(config);
            WebResource wr = client.resource(baseURI);
            ClientResponse response = wr.type("image/*")
                                        .entity(uploadedInputStream)   //legal??
                                        .post(ClientResponse.class);
    }
}
我猜测上述方法的替代方法是临时保存文件,然后将 java.io.File 的实例传递给 entity() 方法。但是,有可能摆脱这种情况吗?