Examples of FilePart


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

        PostMethod method = new PostMethod();
        byte[] content = "Hello".getBytes();
        MultipartRequestEntity entity = new MultipartRequestEntity(
            new Part[] {
                new FilePart(
                    "param1",
                    new ByteArrayPartSource("filename.txt", content),
                    "text/plain",
                    "ISO-8859-1") },
            method.getParams());
View Full Code Here

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

    // ----------------------------------------------------------------- Tests

    public void testFilePartResendsFileData() throws Exception {
        File file = createTempTestFile();
        FilePart part = new FilePart(NAME, file);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp1 = stream.toString();
        stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp2 = stream.toString();
        file.delete();
        assertEquals(resp1, resp2);
    }
View Full Code Here

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

        String resp2 = stream.toString();
        assertEquals(resp1, resp2);
    }

    public void testFilePartNullFileResendsData() throws Exception {
        FilePart part = new FilePart(NAME, "emptyfile.ext", null);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp1 = stream.toString();
        stream = new ByteArrayOutputStream();
        part.send(stream);
        String resp2 = stream.toString();
        assertEquals(resp1, resp2);
    }
View Full Code Here

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

    public void testMultipartRequestTooLarge() throws Exception {
        PostMethod post = new PostMethod("http://localhost:" + PORT + "/bookstore/books/image");
        String ct = "multipart/mixed";
        post.setRequestHeader("Content-Type", ct);
        Part[] parts = new Part[1];
        parts[0] = new FilePart("image",
                new ByteArrayPartSource("testfile.png", new byte[1024 * 11]),
                "image/png", null);
        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));

        HttpClient httpclient = new HttpClient();
View Full Code Here

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

    public void testMultipartRequestTooLargeManyParts() throws Exception {
        PostMethod post = new PostMethod("http://localhost:" + PORT + "/bookstore/books/image");
        String ct = "multipart/mixed";
        post.setRequestHeader("Content-Type", ct);
        Part[] parts = new Part[2];
        parts[0] = new FilePart("image",
                new ByteArrayPartSource("testfile.png", new byte[1024 * 9]),
                "image/png", null);
        parts[1] = new FilePart("image",
                new ByteArrayPartSource("testfile2.png", new byte[1024 * 11]),
                "image/png", null);
        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));

        HttpClient httpclient = new HttpClient();
View Full Code Here

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

    }

    public void testMimeWithHttpClient() throws Exception {
        File f = new File(getClass().getResource("servicemix.jpg").getFile());
        PostMethod filePost = new PostMethod("http://localhost:8192/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

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

            params.add(new StringPart("minute", parameters[9]));
            params.add(new StringPart("tags", parameters[2]));

            params.add(new StringPart("submitter_user_name", username));
            // We do the images last, not to split the fields into parts
            params.add(new FilePart("upload_image", eventImg));
            params.add(new FilePart("upload_literature", eventPdf));
            params.add(new StringPart("addeventsubmit", "Create"));           
            ((ApacheHC3Transport) http).fetchURL(addEventResultURL, params);

            int status = http.getResponseCode();
            String[] locationHeader = http.getResponseHeader("location");
View Full Code Here

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

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

        params.add(new StringPart("telephone", parameters[5]));
        params.add(new StringPart("timezone", parameters[7]));
        params.add(new FilePart("user_image", personImg));
        params.add(new StringPart("summary", parameters[6]));
        params.add(new StringPart("addpersonsubmit", "Create"));
      
        ((ApacheHC3Transport)http).fetchURL(addPersonResultURL, params);
View Full Code Here

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

     */
    public void addParameter(String parameterName, File parameterFile)
    throws FileNotFoundException {
        LOG.trace("enter MultipartPostMethod.addParameter(String parameterName, "
            + "File parameterFile)");
        Part param = new FilePart(parameterName, parameterFile);
        parameters.add(param);
    }
View Full Code Here

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

     */
    public void addParameter(String parameterName, String fileName, File parameterFile)
    throws FileNotFoundException {
        LOG.trace("enter MultipartPostMethod.addParameter(String parameterName, "
            + "String fileName, File parameterFile)");
        Part param = new FilePart(parameterName, fileName, parameterFile);
        parameters.add(param);
    }
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.