Package org.apache.http.entity.mime

Examples of org.apache.http.entity.mime.MultipartEntityBuilder.addPart()


    if (hasFile) {
      MultipartEntityBuilder builder = MultipartEntityBuilder.create();
      for(String key: keyOrder) {
        Object value = parameters.get(key);
        if (value instanceof File) {
          builder.addPart(key, new FileBody((File) value));
        } else {
          builder.addPart(key, new StringBody(value.toString(), ContentType.create(ContentType.APPLICATION_FORM_URLENCODED.getMimeType(), Charset.forName(UTF_8))));
        }
      }
      return builder.build();
View Full Code Here


      for(String key: keyOrder) {
        Object value = parameters.get(key);
        if (value instanceof File) {
          builder.addPart(key, new FileBody((File) value));
        } else {
          builder.addPart(key, new StringBody(value.toString(), ContentType.create(ContentType.APPLICATION_FORM_URLENCODED.getMimeType(), Charset.forName(UTF_8))));
        }
      }
      return builder.build();
    } else {
      try {
View Full Code Here

    Map<String, String> params = WxUtil.getAccessTokenParams(accessToken);
    System.out.println(typeString);
    params.put("type", typeString);
    ContentBody contentBody = new ByteArrayBody(content, ContentType.MULTIPART_FORM_DATA, "name.jpg");
    entityBuilder.addPart("media", contentBody);
    MediaResultMapper result = WxUtil.sendRequest(
        config.getMediaUploadUrl(), HttpMethod.POST, params,
        entityBuilder.build(), MediaResultMapper.class);

    WxBaseItemMediaEntity resultEntity = null;
View Full Code Here

    File file = new File("small");
    URL small = new URL(VideoURLs.map.get("small-webm"));
    FileUtils.copyURLToFile(small, file);
    FileBody fb = new FileBody(file);
    multipartEntity.addPart("file", fb);

    HttpEntity httpEntity = multipartEntity.build();
    post.setEntity(httpEntity);

    EntityUtils.consume(httpEntity);
View Full Code Here

      InputStream is = getClass().getResourceAsStream("/UploadTestFile.txt");

      MultipartEntityBuilder builder = MultipartEntityBuilder.create();
      ContentBody cbFile = new InputStreamBody(is,
          ContentType.create("text/plain"), "UploadTestFile.txt");
      builder.addPart("fileUpload", cbFile);
      builder.addPart("extTID", new StringBody("2", ContentType.DEFAULT_TEXT));
      builder.addPart("extAction", new StringBody("fileUploadService",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extMethod", new StringBody("uploadTest",
          ContentType.DEFAULT_TEXT));
View Full Code Here

      MultipartEntityBuilder builder = MultipartEntityBuilder.create();
      ContentBody cbFile = new InputStreamBody(is,
          ContentType.create("text/plain"), "UploadTestFile.txt");
      builder.addPart("fileUpload", cbFile);
      builder.addPart("extTID", new StringBody("2", ContentType.DEFAULT_TEXT));
      builder.addPart("extAction", new StringBody("fileUploadService",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extMethod", new StringBody("uploadTest",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extType", new StringBody("rpc", ContentType.DEFAULT_TEXT));
View Full Code Here

      MultipartEntityBuilder builder = MultipartEntityBuilder.create();
      ContentBody cbFile = new InputStreamBody(is,
          ContentType.create("text/plain"), "UploadTestFile.txt");
      builder.addPart("fileUpload", cbFile);
      builder.addPart("extTID", new StringBody("2", ContentType.DEFAULT_TEXT));
      builder.addPart("extAction", new StringBody("fileUploadService",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extMethod", new StringBody("uploadTest",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extType", new StringBody("rpc", ContentType.DEFAULT_TEXT));
      builder.addPart("extUpload", new StringBody("true", ContentType.DEFAULT_TEXT));
View Full Code Here

          ContentType.create("text/plain"), "UploadTestFile.txt");
      builder.addPart("fileUpload", cbFile);
      builder.addPart("extTID", new StringBody("2", ContentType.DEFAULT_TEXT));
      builder.addPart("extAction", new StringBody("fileUploadService",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extMethod", new StringBody("uploadTest",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extType", new StringBody("rpc", ContentType.DEFAULT_TEXT));
      builder.addPart("extUpload", new StringBody("true", ContentType.DEFAULT_TEXT));

      builder.addPart(
View Full Code Here

      builder.addPart("extTID", new StringBody("2", ContentType.DEFAULT_TEXT));
      builder.addPart("extAction", new StringBody("fileUploadService",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extMethod", new StringBody("uploadTest",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extType", new StringBody("rpc", ContentType.DEFAULT_TEXT));
      builder.addPart("extUpload", new StringBody("true", ContentType.DEFAULT_TEXT));

      builder.addPart(
          "name",
          new StringBody("Jimöäü", ContentType.create("text/plain",
View Full Code Here

      builder.addPart("extAction", new StringBody("fileUploadService",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extMethod", new StringBody("uploadTest",
          ContentType.DEFAULT_TEXT));
      builder.addPart("extType", new StringBody("rpc", ContentType.DEFAULT_TEXT));
      builder.addPart("extUpload", new StringBody("true", ContentType.DEFAULT_TEXT));

      builder.addPart(
          "name",
          new StringBody("Jimöäü", ContentType.create("text/plain",
              Charset.forName("UTF-8"))));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.