Package org.apache.commons.httpclient.methods.multipart

Examples of org.apache.commons.httpclient.methods.multipart.StringPart


        File file = new File("src/main/resources/META-INF/NOTICE.txt");

        PostMethod httppost = new PostMethod("http://localhost:9080/test");
        Part[] parts = {
            new StringPart("comment", "A binary file of some kind"),
            new FilePart(file.getName(), file)
        };

        MultipartRequestEntity reqEntity = new MultipartRequestEntity(parts, httppost.getParams());
        httppost.setRequestEntity(reqEntity);
View Full Code Here


        parts = new Part[params.length + 1];
      }
      if (params != null) {
        int i = 0;
        for (PostParameter entry : params) {
          parts[i++] = new StringPart(entry.getName(),
              (String) entry.getValue());
        }
        parts[parts.length - 1] = new ByteArrayPart(item.getContent(),
            item.getName(), item.getContentType());
      }
View Full Code Here

        parts = new Part[params.length + 1];
      }
      if (params != null) {
        int i = 0;
        for (PostParameter entry : params) {
          parts[i++] = new StringPart(entry.getName(),
              (String) entry.getValue());
        }
      }
      FilePart filePart = new FilePart(fileParamName, file.getName(),
          file, new MimetypesFileTypeMap().getContentType(file),
View Full Code Here

                HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
                String parameterName = arg.getName();
                if (arg.isSkippable(parameterName)){
                    continue;
                }
                StringPart part = new StringPart(arg.getName(), arg.getValue(), contentEncoding);
                if (browserCompatible) {
                    part.setTransferEncoding(null);
                    part.setContentType(null);
                }
                partlist.add(part);
            }

            // Add any files
View Full Code Here

        parts = new Part[params.length + 1];
      }
      if (params != null) {
        int i = 0;
        for (PostParameter entry : params) {
          parts[i++] = new StringPart(entry.getName(),
              (String) entry.getValue());
        }
      }
      FilePart filePart = new FilePart(fileParamName, file.getName(),
          file, new MimetypesFileTypeMap().getContentType(file),
View Full Code Here

        parts = new Part[params.length + 1];
      }
      if (params != null) {
        int i = 0;
        for (PostParameter entry : params) {
          parts[i++] = new StringPart(entry.getName(),
              (String) entry.getValue());
        }
      }
      FilePart filePart = new FilePart(fileParamName, file.getName(),
          file, new MimetypesFileTypeMap().getContentType(file),
View Full Code Here

         *
         * @param paramName
         * @param value
         */
        private void addPart(String paramName, String value) {
            parts.add(new StringPart(paramName, value));
        }
View Full Code Here

            switch (value.getType()) {
                case PropertyType.BINARY:
                    part = new FilePart(paramName, new BinaryPartSource(value));
                    break;
                case PropertyType.NAME:
                    part = new StringPart(paramName, resolver.getJCRName(value.getName()));
                    break;
                case PropertyType.PATH:
                    part = new StringPart(paramName, resolver.getJCRPath(value.getPath()));
                    break;
                default:
                    part = new StringPart(paramName, value.getString());
            }
            String ctype = JcrValueType.contentTypeFromType(value.getType());
            ((PartBase) part).setContentType(ctype);

            parts.add(part);
View Full Code Here

    }

    public void testMimeWithHttpClient() throws Exception {
        File f = new File(getClass().getResource("servicemix.jpg").getFile());
        PostMethod filePost = new PostMethod("http://localhost:18192/Service/");
        Part[] parts = {new StringPart("request", "<dummy/>"), new FilePart(f.getName(), f)};
        RequestEntity entity = new MultipartRequestEntity(parts, filePost.getParams());
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        entity.writeRequest(baos);
        logger.info(baos);
        filePost.setRequestEntity(entity);
View Full Code Here

       
        PostMethod filePost = new PostMethod(targetURL);
        try {
            Part[] parts = {
                new FilePart(file.getName(), new FilePartSource(file.getName(),
                    file)), new StringPart("_noredir_", "_noredir_") };
            filePost.setRequestEntity(new MultipartRequestEntity(parts,
                filePost.getParams()));
            HttpClient client = new HttpClient();
            client.getHttpConnectionManager().getParams().setConnectionTimeout(
                5000);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.methods.multipart.StringPart

Copyright © 2018 www.massapicom. 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.