use of com.sun.jersey.multipart.file.FileDataBodyPart in project coprhd-controller by CoprHD.
the class StorageDriver method upgradeDriver.
public ClientResponse upgradeDriver(String driverName, File driverFile, boolean force) {
FormDataMultiPart multiPart = new FormDataMultiPart();
multiPart.bodyPart(new FileDataBodyPart(DRIVER_KEY_NAME, driverFile, MediaType.APPLICATION_OCTET_STREAM_TYPE));
multiPart.field("force", Boolean.toString(force));
return client.postMultiPart(ClientResponse.class, multiPart, PathConstants.STORAGE_DRIVER_UPGRADE_URL, driverName);
}
use of com.sun.jersey.multipart.file.FileDataBodyPart in project coprhd-controller by CoprHD.
the class StorageDriver method installDriver.
public ClientResponse installDriver(File f) {
FormDataMultiPart multiPart = new FormDataMultiPart();
multiPart.bodyPart(new FileDataBodyPart(DRIVER_KEY_NAME, f, MediaType.APPLICATION_OCTET_STREAM_TYPE));
return client.postMultiPart(ClientResponse.class, multiPart, PathConstants.STORAGE_DRIVER_INSTALL_URL);
}
use of com.sun.jersey.multipart.file.FileDataBodyPart in project java-docs-samples by GoogleCloudPlatform.
the class MailgunServlet method sendComplexMessage.
// [END simple]
// [START complex]
private ClientResponse sendComplexMessage(String recipient) {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("api", MAILGUN_API_KEY));
WebResource webResource = client.resource("https://api.mailgun.net/v3/" + MAILGUN_DOMAIN_NAME + "/messages");
FormDataMultiPart formData = new FormDataMultiPart();
formData.field("from", "Mailgun User <mailgun@" + MAILGUN_DOMAIN_NAME + ">");
formData.field("to", recipient);
formData.field("subject", "Complex Mailgun Example");
formData.field("html", "<html>HTML <strong>content</strong></html>");
ClassLoader classLoader = getClass().getClassLoader();
File txtFile = new File(classLoader.getResource("example-attachment.txt").getFile());
formData.bodyPart(new FileDataBodyPart("attachment", txtFile, MediaType.TEXT_PLAIN_TYPE));
return webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class, formData);
}
use of com.sun.jersey.multipart.file.FileDataBodyPart in project atlas by apache.
the class AtlasBaseClient method importData.
public AtlasImportResult importData(AtlasImportRequest request, String absoluteFilePath) throws AtlasServiceException {
FileDataBodyPart filePart = new FileDataBodyPart("data", new File(absoluteFilePath));
MultiPart multipartEntity = new FormDataMultiPart().field("request", AtlasType.toJson(request), MediaType.APPLICATION_JSON_TYPE).bodyPart(filePart);
return callAPI(IMPORT, AtlasImportResult.class, multipartEntity);
}
use of com.sun.jersey.multipart.file.FileDataBodyPart in project java-docs-samples by GoogleCloudPlatform.
the class MailgunServlet method sendComplexMessage.
// [END simple]
// [START complex]
private ClientResponse sendComplexMessage(String recipient) {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("api", MAILGUN_API_KEY));
FormDataMultiPart formData = new FormDataMultiPart();
formData.field("from", "Mailgun User <mailgun@" + MAILGUN_DOMAIN_NAME + ">");
formData.field("to", recipient);
formData.field("subject", "Complex Mailgun Example");
formData.field("html", "<html>HTML <strong>content</strong></html>");
ClassLoader classLoader = getClass().getClassLoader();
File txtFile = new File(classLoader.getResource("example-attachment.txt").getFile());
formData.bodyPart(new FileDataBodyPart("attachment", txtFile, MediaType.TEXT_PLAIN_TYPE));
WebResource webResource = client.resource("https://api.mailgun.net/v3/" + MAILGUN_DOMAIN_NAME + "/messages");
return webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(ClientResponse.class, formData);
}
Aggregations