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

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


            List<Part> partList = new ArrayList<Part>();
            partList.add(new StringPart("action", "install"));
            partList.add(new StringPart("_noredir_", "_noredir_"));
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            IOUtils.copy(in, baos);
            PartSource partSource = new ByteArrayPartSource(fileName, baos.toByteArray());
            partList.add(new FilePart("bundlefile", partSource));
            partList.add(new StringPart("bundlestart", "start"));

            Part[] parts = partList.toArray(new Part[partList.size()]);
View Full Code Here


                int i = 0;
                for (ContentStream content : streams) {
                  final ContentStream c = content;

                  String charSet = null;
                  PartSource source = new PartSource() {
                    public long getLength() {
                      return c.getSize();
                    }
                    public String getFileName() {
                      return c.getName();
View Full Code Here

    this.signInResult = signInResult;
    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

 
  public static RegistrationResult register(String username, String password,
      String ontologyUri, String fileName, String fileContents, String graphId
  ) throws HttpException, IOException {
   
    PartSource partSource = new ByteArrayPartSource(fileName, fileContents.getBytes());
   
    System.out.println("Executing POST request to " +FORM_ACTION);
    PostMethod post = new PostMethod(FORM_ACTION);
    post.addRequestHeader("accept", "text/plain");
    try {
View Full Code Here

    uri="http://cashtracking.appspot.com/profiler/sessionInit";
    try {
      PostMethod method = new PostMethod(uri);
      String str=login();
     
      PartSource partSource = new FilePartSource(new File(
          Instrumentor.D_TEMP_CD));
      HttpMethodParams params = new HttpMethodParams();
      FilePart filePart = new FilePart("profiler", partSource);
      MultipartRequestEntity multipartRequestEntity = new MultipartRequestEntity(
          new Part[] { filePart }, params);
View Full Code Here

  public static RegistrationResult register(String username, String password,
      String ontologyUri, String fileName, String fileContents, String graphId,
      String formAction
  ) throws HttpException, IOException {
   
    PartSource partSource = new ByteArrayPartSource(fileName, fileContents.getBytes("UTF-8"));
   
    System.out.println("Executing POST request to " +formAction);
    PostMethod post = new PostMethod(formAction);
    post.addRequestHeader("accept", "text/plain");
    try {
View Full Code Here

            out.write(QUOTE_BYTES);
        }
    }

    public void dispose() {
        PartSource src = getSource();
        if (src instanceof BinaryPartSource) {
            ((BinaryPartSource) src).dispose();
        }
    }
View Full Code Here

       
        activeMethod = new PostMethod(fullPostURL);
        /* Set HTTP Parameter Cookie to the user provided values (actually current session) */
        activeMethod.setRequestHeader("Cookie", policy.getSessionString());
       
        PartSource fps = this.getFilePartSource();
        String fileName = fps.getFileName();
        Part[] parts = {new FilePart(fileName, fps, null, "UTF-8")};

        /* Raise upload started event */
        this.notifyListeners(EVT_STARTED, fps.getLength(), 0);
       
        try{
           activeMethod.setRequestEntity(new MultipartRequestEntity(parts, activeMethod.getParams()));           
          
           HttpClient client = new HttpClient();  
View Full Code Here

    private FilePart convertFileUploadToFilePart(final TextFileUpload txtFileUpload, StringBuilder expectedResponse) {

        final String filePartName = "fileUpload";

        FilePart filePart = new FilePart(filePartName, new PartSource() {
            private byte data[] = txtFileUpload.getData().getBytes();

            @Override
            public long getLength() {
                return data.length;
View Full Code Here

                        ((FilePart) part).getFile(),
                        ((FilePart) part).getMimeType(),
                        ((FilePart) part).getCharSet());

            } else if (part instanceof ByteArrayPart) {
                PartSource source = new ByteArrayPartSource(((ByteArrayPart) part).getFileName(), ((ByteArrayPart) part).getData());
                parts[i] = new org.apache.commons.httpclient.methods.multipart.FilePart(part.getName(),
                        source,
                        ((ByteArrayPart) part).getMimeType(),
                        ((ByteArrayPart) part).getCharSet());
View Full Code Here

TOP

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

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.