I have the following method in a service:
public interface MyService {
@POST
@Path("/upload-file")
@Consumes(MediaType.MULTIPART_FORM_DATA)
void uploadFile(@FormDataParam("file") InputStream inputStream,
@FormDataParam("file") FormDataContentDisposition contentDisposition);
}
and I create an instance of this interface using WebResourceFactory:
final MyService buildProxy() {
final ClientBuilder clientBuidler = ClientBuilder.newBuilder();
// register components, trust manager, etc.
final WebTarget target = clientBuilder.build().target("http://myservice.example.com");
return WebResourceFactory.newResource(
MyService.class, target, false, ImmutableMultivaluedMap.empty(),
Collections.emptyList(), new Form());
}
I want to call my method using this proxy, but I can't find a convenient way to create a FormDataContentDisposition. Is my best bet really going to be to create the header string, and then pass that into new FormDataContentDisposition(String header)? Can I relax my types somewhere to get access to a more convenient constructor? Is there a different, more convenient interface I can use in a file-upload? I'm mainly including the content-disposition in my interface so I can reject a file that is too large before I save the entire thing to disk.