List of usage examples for org.apache.http.entity.mime.content StringBody StringBody
public StringBody(final String text) throws UnsupportedEncodingException
From source file:net.asplode.tumblr.VideoPost.java
public VideoPost() { try {/*from w w w . j a va 2 s .c o m*/ entity.addPart("type", new StringBody("video")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:net.asplode.tumblr.PhotoPost.java
public PhotoPost() { try {//w w w .ja v a2s.co m entity.addPart("type", new StringBody("photo")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:net.asplode.tumblr.ReblogPost.java
/** * @param key// ww w . j a va2 s . co m * Reblog key of the original post * @throws UnsupportedEncodingException */ public void setReblogKey(String key) throws UnsupportedEncodingException { entity.addPart("reblog-key", new StringBody(key)); }
From source file:net.asplode.tumblr.LinkPost.java
/** * @param url URL/* www. j a v a 2 s . co m*/ * @throws UnsupportedEncodingException */ public void setURL(String url) throws UnsupportedEncodingException { entity.addPart("url", new StringBody(url)); }
From source file:net.asplode.tumblr.QuotePost.java
/** * @param quote Quote/*from w w w . j a va2 s . c o m*/ * @throws UnsupportedEncodingException */ public void setQuote(String quote) throws UnsupportedEncodingException { entity.addPart("quote", new StringBody(quote)); }
From source file:net.asplode.tumblr.ConversationPost.java
/** * @param title Conversation title//from ww w .j av a 2s . c om * @throws UnsupportedEncodingException */ public void setTitle(String title) throws UnsupportedEncodingException { entity.addPart("title", new StringBody(title)); }
From source file:ADP_Streamline.CURL2.java
public String uploadFiles(File file, String siteId, String containerId, String uploadDirectory) { String json = null;// www. j av a 2 s . c o m DefaultHttpClient httpclient = new DefaultHttpClient(); HttpHost targetHost = new HttpHost("localhost", 8080, "http"); try { HttpPost httppost = new HttpPost("/alfresco/service/api/upload?alf_ticket=" + this.ticket); FileBody bin = new FileBody(file); StringBody siteid = new StringBody(siteId); StringBody containerid = new StringBody(containerId); StringBody uploaddirectory = new StringBody(uploadDirectory); MultipartEntity reqEntity = new MultipartEntity(); reqEntity.addPart("filedata", bin); reqEntity.addPart("siteid", siteid); reqEntity.addPart("containerid", containerid); reqEntity.addPart("uploaddirectory", uploaddirectory); httppost.setEntity(reqEntity); //log.debug("executing request:" + httppost.getRequestLine()); HttpResponse response = httpclient.execute(targetHost, httppost); HttpEntity resEntity = response.getEntity(); //log.debug("response status:" + response.getStatusLine()); if (resEntity != null) { //log.debug("response content length:" + resEntity.getContentLength()); json = EntityUtils.toString(resEntity); //log.debug("response content:" + json); } EntityUtils.consume(resEntity); } catch (Exception e) { throw new RuntimeException(e); } finally { httpclient.getConnectionManager().shutdown(); } return json; }
From source file:net.asplode.tumblr.AudioPost.java
/** * @param caption Post caption//from w w w . j a v a 2 s . c om * @throws UnsupportedEncodingException */ public void setCaption(String caption) throws UnsupportedEncodingException { entity.addPart("caption", new StringBody(caption)); }
From source file:net.adamcin.commons.testing.sling.RequestBuilderUtil.java
/** * Transforms a {@code Map} of properties into a multipart params entity * @param entity the entity to add the property values to * @param props a map of String properties * @throws UnsupportedEncodingException/*from ww w . ja va2s .c om*/ */ public static void setMultipartParamsFromProps(MultipartEntity entity, Map<String, Object> props) throws UnsupportedEncodingException { if (entity != null) { if (props != null) { for (Map.Entry<String, Object> e : props.entrySet()) { entity.addPart(e.getKey(), new StringBody(e.getValue().toString())); } } } }
From source file:net.asplode.tumblr.ReblogPost.java
/** * @param comment// ww w. j ava2 s. c om * Optional post comment * @throws UnsupportedEncodingException */ public void setComment(String comment) throws UnsupportedEncodingException { entity.addPart("comment", new StringBody(comment)); }