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:" + getPort() + "/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


                String p = iter.next();
                String[] vals = params.getParams(p);
                if (vals != null) {
                  for (String v : vals) {
                    if (this.useMultiPartPost || isMultipart) {
                      parts.add(new StringPart(p, v, "UTF-8"));
                    } else {
                      post.addParameter(p, v);
                    }
                  }
                }
View Full Code Here

            List<Part> listParts = new ArrayList<Part>();
            // Iterate the multipart items list
            for(FileItem fileItemCurrent : listFileItems) {
                // If the current item is a form field, then create a string part
                if (fileItemCurrent.isFormField()) {
                    StringPart stringPart = new StringPart(
                            fileItemCurrent.getFieldName(), // The field name
                            fileItemCurrent.getString()     // The field value
                    );
                    // Add the part to the list
                    listParts.add(stringPart);
View Full Code Here

               HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
               String parameterName = arg.getName();
               if (parameterName.length()==0){
                   continue; // Skip parameters with a blank name (allows use of optional variables in parameter lists)
               }
               parts[partNo++] = new StringPart(arg.getName(), arg.getValue(), contentEncoding);
            }
           
            // Add any files
            for (int i=0; i < files.length; i++) {
                HTTPFileArg file = files[i];
View Full Code Here

                String p = iter.next();
                String[] vals = params.getParams(p);
                if (vals != null) {
                  for (String v : vals) {
                    if (this.useMultiPartPost || isMultipart) {
                      parts.add(new StringPart(p, v, "UTF-8"));
                    } else {
                      post.addParameter(p, v);
                    }
                  }
                }
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

                                                .getProperty(element, "value") instanceof String) {
                                        eName = (String) ScriptableObject
                                                .getProperty(element, "name");
                                        eValue = (String) ScriptableObject
                                                .getProperty(element, "value");
                                        parts.add(new StringPart(eName, eValue));
                                    } else {
                                        throw new CarbonException(
                                                "Invalid content definition, objects of the content" +
                                                " array should consists with strings for both key/value");
                                    }
View Full Code Here

            String fileName = name;
            final DataHandler dh = msg.getOutboundAttachment(name);
            if (dh.getDataSource() instanceof StringDataSource)
            {
                final StringDataSource ds = (StringDataSource) dh.getDataSource();
                parts[i] = new StringPart(ds.getName(), IOUtils.toString(ds.getInputStream()));
            }
            else
            {
                if (dh.getDataSource() instanceof FileDataSource)
                {
View Full Code Here

            int partNo = 0;
            // Add any parameters
            PropertyIterator args = getArguments().iterator();
            while (args.hasNext()) {
                HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
                parts[partNo++] = new StringPart(arg.getName(), arg.getValue(), contentEncoding);
            }
           
            // Add any files
            if(hasUploadableFiles()) {
                File inputFile = new File(getFilename());
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

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.