Examples of MultipartEntityBuilder


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

      ArrayList<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
      nameValuePairList.add(new BasicNameValuePair("key",""));
      nameValuePairList.add(new BasicNameValuePair("txtenroll","095020693015"));
      httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairList));

        MultipartEntityBuilder multipartEntityBuilder =
            MultipartEntityBuilder.create();
       
        multipartEntityBuilder.addTextBody("foo", "foo body");
        multipartEntityBuilder.addTextBody("foo", "foo body");
        ContentType contentType = ContentType.create("application/octet-stream");
        String filename = "src/test/resources/org/xmlcml/ckan/test.xml";
        File file = new File(filename);
        FileBody fooFileBody = new FileBody(file, contentType);
        // this doesn't compile even though the signatureis offered by Eclipse
//        multipartEntityBuilder.addBinaryBody("foofile", fooFileBody, contentType, filename);
        multipartEntityBuilder.addBinaryBody(filename, new FileInputStream(file), contentType, filename);

        HttpEntity entity = multipartEntityBuilder.build();
        httpPost.setEntity(entity);
       
        HttpResponse response = httpClient.execute(httpPost);
        HttpEntity result = response.getEntity();
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.