Examples of ByteArrayPartSource


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

        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.ByteArrayPartSource

        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.ByteArrayPartSource

        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 * 1024 * 15]),
                "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.ByteArrayPartSource

        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.ByteArrayPartSource

        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.ByteArrayPartSource

            parts = new Part[msg.getOutboundAttachmentNames().size()];
        }
        else
        {
            parts = new Part[msg.getOutboundAttachmentNames().size() + 1];
            parts[i++] = new FilePart("payload", new ByteArrayPartSource("payload", msg.getPayloadAsBytes()));
        }

        for (final Iterator<String> iterator = msg.getOutboundAttachmentNames().iterator(); iterator.hasNext(); i++)
        {
            final String name = iterator.next();
            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)
                {
                    fileName = ((FileDataSource) dh.getDataSource()).getFile().getName();
                }
                else if (dh.getDataSource() instanceof URLDataSource)
                {
                    fileName = ((URLDataSource) dh.getDataSource()).getURL().getFile();
                    // Don't use the whole file path, just the file name
                    final int x = fileName.lastIndexOf("/");
                    if (x > -1)
                    {
                        fileName = fileName.substring(x + 1);
                    }
                }
                parts[i] = new FilePart(dh.getName(), new ByteArrayPartSource(fileName,
                    IOUtils.toByteArray(dh.getInputStream())), dh.getContentType(), null);
            }
        }

        return new MultipartRequestEntity(parts, method.getParams());
View Full Code Here

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

        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.ByteArrayPartSource

        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.ByteArrayPartSource

        // set the given http params on PostMethod
        result.setQueryString(httpParams);

        // legger til en "fil" Dette er egentlig bare en String som ligger lagret i minne.
        ByteArrayPartSource xml;
        try {
            xml = new ByteArrayPartSource("sws.xml", swsXml.getBytes("UTF-8"));
        }
        catch(final UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

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

        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 * 1024 * 15]),
                "image/png", null);
        post.setRequestEntity(new MultipartRequestEntity(parts, post.getParams()));

        HttpClient httpclient = new HttpClient();

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.