当前位置: 首页>>代码示例>>Java>>正文


Java MultiPart.bodyPart方法代码示例

本文整理汇总了Java中org.glassfish.jersey.media.multipart.MultiPart.bodyPart方法的典型用法代码示例。如果您正苦于以下问题:Java MultiPart.bodyPart方法的具体用法?Java MultiPart.bodyPart怎么用?Java MultiPart.bodyPart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.glassfish.jersey.media.multipart.MultiPart的用法示例。


在下文中一共展示了MultiPart.bodyPart方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendFax

import org.glassfish.jersey.media.multipart.MultiPart; //导入方法依赖的package包/类
@Override
public APIResponse sendFax(final String faxNumber,
                           final File[] filesToSendAsFax,
                           final Optional<SendFaxOptions> options) throws IOException, URISyntaxException {

    MultiPart multiPart = new MultiPart();
    int count = 1;
    for (File file : filesToSendAsFax) {
        String contentType = tika.detect(file);
        String entityName = "file"+count++;
        FileDataBodyPart fileDataBodyPart = new FileDataBodyPart(entityName, file, MediaType.valueOf(contentType));
        multiPart.bodyPart(fileDataBodyPart);
    }

    return sendMultiPartFax(faxNumber, multiPart, options);
}
 
开发者ID:interfax,项目名称:interfax-java,代码行数:17,代码来源:DefaultInterFAXClient.java

示例2: convertScript

import org.glassfish.jersey.media.multipart.MultiPart; //导入方法依赖的package包/类
/**
 * @{inheritDoc
 */
public ScriptTO convertScript(ScriptUploadRequest request, InputStream in) throws RestServiceException {
	WebTarget webTarget = client.target(urlBuilder.buildUrl(ScriptService.METHOD_CONVERT_SCRIPT));
    MultiPart multiPart = new MultiPart();
    BodyPart bp = new FormDataBodyPart("file", in, MediaType.APPLICATION_OCTET_STREAM_TYPE);
    multiPart.bodyPart(bp);
    multiPart.bodyPart(new FormDataBodyPart("scriptUploadRequest", request, MediaType.APPLICATION_XML_TYPE));
    Response response = webTarget.request().post(Entity.entity(multiPart,MediaType.MULTIPART_FORM_DATA_TYPE));
    exceptionHandler.checkStatusCode(response);

    String loc = response.getHeaders().getFirst("location").toString();
    webTarget = client.target(loc);
    response = webTarget.request(MediaType.APPLICATION_XML_TYPE).get();
    exceptionHandler.checkStatusCode(response);
    return response.readEntity(ScriptTO.class);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:19,代码来源:ScriptServiceClient.java

示例3: runAutomationJob

import org.glassfish.jersey.media.multipart.MultiPart; //导入方法依赖的package包/类
/**
 * @{inheritDoc
 */
public String runAutomationJob(AutomationRequest request, File xmlFile)
        throws RestServiceException {
	WebTarget webTarget = client.target(baseUrl + METHOD_RUN_JOB);
    MultiPart multiPart = new MultiPart();
    if (xmlFile != null) {
        BodyPart bp = new FileDataBodyPart("file", xmlFile);
        multiPart.bodyPart(bp);
    }

    multiPart.bodyPart(new FormDataBodyPart("automationRequest", request,
            MediaType.APPLICATION_XML_TYPE));
    Response response = webTarget.request().post(Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE));
    exceptionHandler.checkStatusCode(response);
    return response.readEntity(String.class);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:19,代码来源:AutomationServiceClient.java

示例4: multipartPost

import org.glassfish.jersey.media.multipart.MultiPart; //导入方法依赖的package包/类
private Response multipartPost(String path, File resource, String mediaType, Map<String, String> arguments)
  throws ParseException {
  MultiPart formdata = new MultiPart();
  arguments.forEach((key, value) -> formdata.bodyPart(new FormDataBodyPart(key, value)));

  formdata.bodyPart(new FormDataBodyPart(
    new FormDataContentDisposition(
      "form-data; name=\"file\"; filename=\"" + resource.getName().replace("\"", "") + "\""
    ),
    resource,
    MediaType.valueOf(mediaType)
  ));

  Response result = call(path)
    .post(Entity.entity(formdata, "multipart/form-data; boundary=Boundary_1_498293219_1483974344746"));
  return result;
}
 
开发者ID:HuygensING,项目名称:timbuctoo,代码行数:18,代码来源:IntegrationTest.java

示例5: getEntity

import org.glassfish.jersey.media.multipart.MultiPart; //导入方法依赖的package包/类
@Override
public Entity getEntity(List<MultiPartItem> items, String mediaType) {
    MultiPart multiPart = new MultiPart();
    for (MultiPartItem item : items) {
        if (item.getValue() == null || item.getValue().isNull()) {
            continue;
        }
        String name = item.getName();
        String filename = item.getFilename();
        ScriptValue sv = item.getValue();
        String ct = item.getContentType();                    
        if (ct == null) {
            ct = HttpUtils.getContentType(sv);
        }
        MediaType itemType = MediaType.valueOf(ct);
        if (name == null) { // most likely multipart/mixed
            BodyPart bp = new BodyPart().entity(sv.getAsString()).type(itemType);
            multiPart.bodyPart(bp);
        } else if (filename != null) {
            StreamDataBodyPart part = new StreamDataBodyPart(name, sv.getAsStream(), filename, itemType);
            multiPart.bodyPart(part);
        } else {
            multiPart.bodyPart(new FormDataBodyPart(name, sv.getAsString(), itemType));
        }
    }
    return Entity.entity(multiPart, mediaType);
}
 
开发者ID:intuit,项目名称:karate,代码行数:28,代码来源:JerseyHttpClient.java

示例6: uploadFile

import org.glassfish.jersey.media.multipart.MultiPart; //导入方法依赖的package包/类
@Override
public String uploadFile(InputStream inputStream) {
    MultiPart multiPart = new MultiPart();
    BodyPart filePart = new StreamDataBodyPart("file", inputStream, "file");
    multiPart.bodyPart(filePart);
    return Subject.doAs(subject, new PrivilegedAction<String>() {
        @Override
        public String run() {
            return currentSchemaRegistryTargets().filesTarget.request()
                                                             .post(Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA), String.class);
        }
    });
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:14,代码来源:SchemaRegistryClient.java

示例7: updateTankScript

import org.glassfish.jersey.media.multipart.MultiPart; //导入方法依赖的package包/类
/**
 * @{inheritDoc
 */
public String updateTankScript(InputStream in) throws RestServiceException {
	WebTarget webTarget = client.target(urlBuilder.buildUrl(ScriptService.METHOD_SCRIPT_UPDATE));
    MultiPart multiPart = new MultiPart();
    BodyPart bp = new FormDataBodyPart("file", in, MediaType.APPLICATION_OCTET_STREAM_TYPE);
    multiPart.bodyPart(bp);
    Response response = webTarget.request(MediaType.TEXT_PLAIN_TYPE).post(Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE));
    exceptionHandler.checkStatusCode(response);
    return response.readEntity(String.class);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:13,代码来源:ScriptServiceClient.java

示例8: handleRequest

import org.glassfish.jersey.media.multipart.MultiPart; //导入方法依赖的package包/类
private Response handleRequest(AbstractUploadRequest abstractUploadRequest, BodyPart bodyPart) {
    final WebTarget webTarget = client.target(directUploadUrl);

    final MultiPart multiPart = new MultiPart();
    multiPart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE);

    multiPart.bodyPart(new FormDataBodyPart(DATA_PART, wrapAuth(abstractUploadRequest), MediaType.APPLICATION_JSON_TYPE));
    multiPart.bodyPart(bodyPart);

    return webTarget.request(MediaType.APPLICATION_JSON_TYPE).post(Entity.entity(multiPart, multiPart.getMediaType()));
}
 
开发者ID:kraken-io,项目名称:kraken-java,代码行数:12,代码来源:DefaultKrakenIoClient.java


注:本文中的org.glassfish.jersey.media.multipart.MultiPart.bodyPart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。