org.glassfish.jersey.media.multipart.internal.MultiPartWriter Java Examples

The following examples show how to use org.glassfish.jersey.media.multipart.internal.MultiPartWriter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReportResourceIT.java    From difido-reports with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	super.setUp();
	String baseUri = "http://0.0.0.0:8080/api/";
	jerseyClient = ClientBuilder.newClient();
	jerseyClient.register(JacksonFeature.class);
	jerseyClient.register(MultiPartWriter.class);
	this.baseTarget = jerseyClient.target(baseUri);
	jerseyClient.target(baseUri);
	AddExecutions();

}
 
Example #2
Source File: BscClient.java    From bce-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 * load ${cert} for ${jobId}job
 * @param jobId
 * @param cert
 * @return
 */
public Resp<UploadCertResponse> uploadCert(Long jobId, File cert) {
    MultiPart multiPart = new FormDataMultiPart().bodyPart(
        new FileDataBodyPart("file", cert, MediaType.MULTIPART_FORM_DATA_TYPE)
    );

    BceClientConfig config = BceClientConfig.newDefaultBceClientConfig()
                                            .withMessageBodyWriterClass(MultiPartWriter.class);

    return super.createAuthorizedRequest(config)
                .path(certURL + "/upload/" + jobId)
                .postWithResponse(new Entity(multiPart, MediaType.MULTIPART_FORM_DATA))
                .getEntity(new GenericType<Resp<UploadCertResponse>>() { });
}