Examples of MultipartEntityBuilder


Examples of com.atlassian.httpclient.apache.httpcomponents.MultiPartEntityBuilder

  }

  private Promise<Void> postAttachments(final URI attachmentsUri, final MultipartEntity multipartEntity) {
    final ResponsePromise responsePromise = client()
        .newRequest(attachmentsUri)
        .setEntity(new MultiPartEntityBuilder(multipartEntity))
        .setHeader("X-Atlassian-Token", "nocheck")
        .post();
    return call(responsePromise);
  }
View Full Code Here

Examples of com.atlassian.httpclient.apache.httpcomponents.MultiPartEntityBuilder

  }

  private Promise<Void> postAttachments(final URI attachmentsUri, final MultipartEntity multipartEntity) {
    final ResponsePromise responsePromise = client()
        .newRequest(attachmentsUri)
        .setEntity(new MultiPartEntityBuilder(multipartEntity))
        .setHeader("X-Atlassian-Token", "nocheck")
        .post();
    return call(responsePromise);
  }
View Full Code Here

Examples of com.atlassian.httpclient.apache.httpcomponents.MultiPartEntityBuilder

  }

  private Promise<Void> postAttachments(final URI attachmentsUri, final MultipartEntity multipartEntity) {
    final ResponsePromise responsePromise = client()
        .newRequest(attachmentsUri)
        .setEntity(new MultiPartEntityBuilder(multipartEntity))
        .setHeader("X-Atlassian-Token", "nocheck")
        .post();
    return call(responsePromise);
  }
View Full Code Here

Examples of com.atlassian.httpclient.apache.httpcomponents.MultiPartEntityBuilder

  }

  private Promise<Void> postAttachments(final URI attachmentsUri, final MultipartEntity multipartEntity) {
    final ResponsePromise responsePromise = client()
        .newRequest(attachmentsUri)
        .setEntity(new MultiPartEntityBuilder(multipartEntity))
        .setHeader("X-Atlassian-Token", "nocheck")
        .post();
    return call(responsePromise);
  }
View Full Code Here

Examples of com.atlassian.httpclient.apache.httpcomponents.MultiPartEntityBuilder

  }

  private Promise<Void> postAttachments(final URI attachmentsUri, final MultipartEntity multipartEntity) {
    final ResponsePromise responsePromise = client()
        .newRequest(attachmentsUri)
        .setEntity(new MultiPartEntityBuilder(multipartEntity))
        .setHeader("X-Atlassian-Token", "nocheck")
        .post();
    return call(responsePromise);
  }
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntityBuilder

  public String getBody() {
    if (body != null) {
      return body;
    }
    if (!bodyParts.isEmpty()) {
      MultipartEntityBuilder builder = MultipartEntityBuilder.create();
      for (BodyPart bodyPart : bodyParts) {
        bodyPart.addPart(builder);
      }
      return builder.build().toString();
    }
    return null;
  }
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntityBuilder

      this.contentParts = content;
    }
   
    @Override
    protected HttpEntity createEntity() throws ClientServicesException {
      MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
      for (ContentPart contentPart : contentParts) {
        if (contentPart.getData() instanceof InputStream) {
          entityBuilder.addBinaryBody(contentPart.getName(),
              (InputStream)contentPart.getData(),
              contentPart.getContentType(),
              contentPart.getFileName());
        }
        else if (contentPart.getData() instanceof byte[]) {
          entityBuilder.addBinaryBody(contentPart.getName(),
              (byte[])contentPart.getData(),
              contentPart.getContentType(),
              contentPart.getFileName());
        }
        else if (contentPart.getData() instanceof String) {
          entityBuilder.addTextBody(contentPart.getName(),
              (String)contentPart.getData(),
              contentPart.getContentType());
        }
      }
      return entityBuilder.build();
    }
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntityBuilder

   */
  public Result<PicUploadResult> uploadPic(String oAuthConsumerKey, String accessToken,
      String openid, String title, byte[] picture, String photoDesc, String albumId,
      Boolean mobile, Double lon, Double lat, Boolean needFeed, Integer successNum, Integer picNum) {
    HttpPost request = new HttpPost("https://graph.qq.com/photo/upload_pic");
    MultipartEntityBuilder builder =
        MultipartEntityBuilder.create().addBinaryBody("picture", picture,
            ContentType.create("image/" + title.substring(title.lastIndexOf(".") + 1)), title);
    builder.addTextBody("oauth_consumer_key", oAuthConsumerKey);
    builder.addTextBody("access_token", accessToken);
    builder.addTextBody("openid", openid);
    builder.addTextBody("format", "json");
    builder.addTextBody("title", title);
    if (photoDesc != null) {
      builder.addTextBody("photodesc", photoDesc);
    }
    if (albumId != null) {
      builder.addTextBody("albumid", albumId);
    }
    if (Boolean.TRUE.equals(mobile)) {
      builder.addTextBody("mobile", "1");
    }
    if (lon != null) {
      builder.addTextBody("x", lon.toString());
    }
    if (lat != null) {
      builder.addTextBody("y", lat.toString());
    }
    if (Boolean.FALSE.equals(needFeed)) {
      builder.addTextBody("needfeed", "0");
    }
    if (successNum != null) {
      builder.addTextBody("successnum", successNum.toString());
    }
    if (picNum != null) {
      builder.addTextBody("picnum", picNum.toString());
    }
    request.setEntity(builder.build());
    try {
      HttpResponse response = Http.CLIENT.execute(request);
      String json = IOUtils.toString(response.getEntity().getContent());
      return Result.parse(json, PicUploadResult.class);
    } catch (ClientProtocolException e) {
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntityBuilder

   */
  public Result<NewT> addPicT(String accessToken, String oauthConsumerKey, String openId,
      String content, byte[] pic, String clientIp, Double lon, Double lat, Boolean sync,
      Boolean compatible) {
    HttpPost request = new HttpPost("https://graph.qq.com/t/add_pic_t");
    MultipartEntityBuilder builder = MultipartEntityBuilder.create().addBinaryBody("pic", pic);

    List<NameValuePair> params = new ArrayList<NameValuePair>();
    addParameter(params, "access_token", accessToken);
    addParameter(params, "oauth_consumer_key", oauthConsumerKey);
    addParameter(params, "openid", openId);
    addParameter(params, "content", content);
    addNotNullParameter(params, "clientip", clientIp);
    addNotNullParameter(params, "lon", lon);
    addNotNullParameter(params, "lat", lat);
    if (sync != null) {
      addParameter(params, "syncflag", sync ? "0" : "1");
    }
    if (compatible != null) {
      addParameter(params, "compatibleflag", compatible ? "0" : "0x20");
    }
    addParameter(params, "format", "json");

    for (NameValuePair nameValuePair : params) {
      builder.addTextBody(nameValuePair.getName(), nameValuePair.getValue());
    }
    request.setEntity(builder.build());
    try {
      HttpResponse response = Http.CLIENT.execute(request);
      String json = IOUtils.toString(response.getEntity().getContent());
      JSONObject jsonObject = new JSONObject(json);
      Error error = Error.parse(jsonObject);
View Full Code Here

Examples of org.apache.http.entity.mime.MultipartEntityBuilder

    return this;
  }
 
  public HttpEntity getEntity() {
    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();
    } else {
      try {
        return new UrlEncodedFormEntity(MapUtil.getList(parameters), UTF_8);
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
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.