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

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


            filePost.setRequestHeader("referer", "about:blank");

            List<Part> partList = new ArrayList<Part>();
            partList.add(new StringPart("action", "install"));
            partList.add(new StringPart("_noredir_", "_noredir_"));
            partList.add(new FilePart("bundlefile", new FilePartSource(
                file.getName(), file)));
            partList.add(new StringPart("bundlestartlevel", bundleStartLevel));

            if (bundleStart) {
                partList.add(new StringPart("bundlestart", "start"));
View Full Code Here


            throws MojoExecutionException {
       
        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(
View Full Code Here

                    if (e.getValue() != null) {
                        partList.add(new StringPart(e.getName(), e.getValue(), "UTF-8"));
                    }
                }
                if  (localFile != null) {
                    partList.add(new FilePart(fieldName, localFile));
                    if (typeHint != null) {
                      partList.add(new StringPart(fieldName + "@TypeHint", typeHint));
                    }
                }
                final Part [] parts = partList.toArray(new Part[partList.size()]);
View Full Code Here

    /** Upload to an file node structure, see SLING-168 */
    public void uploadToFileNode(String url, File localFile, String fieldName, String typeHint)
        throws IOException {

        final Part[] parts = new Part[typeHint == null ? 1 : 2];
        parts[0] = new FilePart(fieldName, localFile);
        if (typeHint != null) {
            parts[1] = new StringPart(fieldName + "@TypeHint", typeHint);
        }
        final PostMethod post = new PostMethod(url);
        post.setFollowRedirects(false);
View Full Code Here

    public void uploadToFileNodes(String url, File[] localFiles, String[] fieldNames, String[] typeHints)
        throws IOException {

      List<Part> partsList = new ArrayList<Part>();
      for (int i=0; i < localFiles.length; i++) {
            Part filePart = new FilePart(fieldNames[i], localFiles[i]);
            partsList.add(filePart);
            if (typeHints != null) {
              Part typeHintPart = new StringPart(fieldNames[i] + "@TypeHint", typeHints[i]);
              partsList.add(typeHintPart);
            }
View Full Code Here

        // with session id
        parts = new Part[3];
        parts[0] = new StringPartNoTransferEncoding("sid", sid);
        parts[1] = new StringPartNoTransferEncoding(
            "ImportExportPassword", "");
        parts[2] = new FilePart("ConfigImportFile",
            uploadFile.getName(), uploadFile);
      } else {
        // old style, no session id
        parts = new Part[2];
        parts[0] = new StringPartNoTransferEncoding(
            "ImportExportPassword", "");
        parts[1] = new FilePart("ConfigImportFile",
            uploadFile.getName(), uploadFile);
      }

      mPost.setRequestEntity(new MultipartRequestEntity(parts, mPost
          .getParams()));
View Full Code Here

                    public InputStream createInputStream() throws IOException {
                      return c.getStream();
                    }
                  };
               
                  parts.add(new FilePart(c.getName(), source,
                                         c.getContentType(), charSet));
                }
              }
              if (parts.size() > 0) {
                post.setRequestEntity(new MultipartRequestEntity(parts
View Full Code Here

    this.ontologyId = ontologyId;
    this.ontologyUserId = ontologyUserId;
    this.values = values;
   
    PartSource partSource = new ByteArrayPartSource(fileName, RDF.getBytes(CHARSET_UTF8));
    filePart = new FilePart("filePath", partSource);
    filePart.setCharSet(CHARSET_UTF8);
  }
View Full Code Here

    try {
      Part[] parts = new Part[] {
          new StringPart("username", username),
          new StringPart("password", password),
          new StringPart("ontologyUri", ontologyUri),
          new FilePart("ontologyFile", partSource),
          new StringPart("graphId", graphId),
      };
      post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));
      HttpClient client = new HttpClient();
      client.getHttpConnectionManager().getParams().setConnectionTimeout(5000);
View Full Code Here

            params.add(new StringPart("city", addressArr[2]));
            params.add(new StringPart("state", addressArr[3]));
            params.add(new StringPart("zip", addressArr[4]));
            params.add(new StringPart("country", addressArr[5]));

            params.add(new FilePart("upload_event_image", eventImg));
            params.add(new FilePart("upload_event_literature",eventPdf));
            params.add(new StringPart("submit", "Create"));
            /****
            Part[] parts = new Part[params.size()];
            parts = params.toArray(parts);

View Full Code Here

TOP

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

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.