Package org.apache.http.entity.mime.content

Examples of org.apache.http.entity.mime.content.InputStreamBody


        FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
       
        multipart.addBodyPart(p1);
        multipart.addBodyPart(p2);
       
        multipart.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
View Full Code Here


       
        HttpMultipart multipart = new HttpMultipart();
        multipart.setParent(message);
        FormBodyPart p1 = new FormBodyPart(
                "field1",
                new InputStreamBody(new FileInputStream(tmpfile), s1 + ".tmp"));
        FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), s2 + ".tmp"));
       
        multipart.addBodyPart(p1);
        multipart.addBodyPart(p2);
       
        multipart.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
View Full Code Here

        assertTrue(bytes.length == len);
    }

    public void testNonRepeatable() throws Exception {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("p1", new InputStreamBody(
                new ByteArrayInputStream("blah blah".getBytes()), null));
        entity.addPart("p2", new InputStreamBody(
                new ByteArrayInputStream("yada yada".getBytes()), null));
        assertFalse(entity.isRepeatable());
        assertTrue(entity.isChunked());
        assertTrue(entity.isStreaming());
View Full Code Here

        FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
       
        multipart.addBodyPart(p1);
        multipart.addBodyPart(p2);
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

        FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
       
        multipart.addBodyPart(p1);
        multipart.addBodyPart(p2);
       
        multipart.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
View Full Code Here

       
        HttpMultipart multipart = new HttpMultipart("form-data");
        multipart.setParent(message);
        FormBodyPart p1 = new FormBodyPart(
                "field1",
                new InputStreamBody(new FileInputStream(tmpfile), s1 + ".tmp"));
        FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), s2 + ".tmp"));
       
        multipart.addBodyPart(p1);
        multipart.addBodyPart(p2);
       
        multipart.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
View Full Code Here

        assertEquals(MIME.ENC_8BIT, b2.getTransferEncoding());
    }

    public void testInputStreamBody() throws Exception {
        byte[] stuff = "Stuff".getBytes("US-ASCII");
        InputStreamBody b1 = new InputStreamBody(new ByteArrayInputStream(stuff), "stuff");
        assertEquals(-1, b1.getContentLength());
       
        assertNull(b1.getCharset());
        assertEquals("stuff", b1.getFilename());
        assertEquals("application/octet-stream", b1.getMimeType());
        assertEquals("application", b1.getMediaType());
        assertEquals("octet-stream", b1.getSubType());

        assertEquals(MIME.ENC_BINARY, b1.getTransferEncoding());

        InputStreamBody b2 = new InputStreamBody(
                new ByteArrayInputStream(stuff), "some/stuff", "stuff");
        assertEquals(-1, b2.getContentLength());
        assertNull(b2.getCharset());
        assertEquals("stuff", b2.getFilename());
        assertEquals("some/stuff", b2.getMimeType());
        assertEquals("some", b2.getMediaType());
        assertEquals("stuff", b2.getSubType());

        assertEquals(MIME.ENC_BINARY, b2.getTransferEncoding());
    }
View Full Code Here

        assertTrue(bytes.length == len);
    }

    public void testNonRepeatable() throws Exception {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("p1", new InputStreamBody(
                new ByteArrayInputStream("blah blah".getBytes()), null));
        entity.addPart("p2", new InputStreamBody(
                new ByteArrayInputStream("yada yada".getBytes()), null));
        assertFalse(entity.isRepeatable());
        assertTrue(entity.isChunked());
        assertTrue(entity.isStreaming());
View Full Code Here

    }

    public MultipartEntityBuilder addBinaryBody(
            final String name, final InputStream stream, final ContentType contentType,
            final String filename) {
        return addPart(name, new InputStreamBody(stream, contentType, filename));
    }
View Full Code Here

        String url = fedoraClient.getUploadURL();
        HttpPost post = new HttpPost(url);
        post.setHeader(HttpHeaders.CONNECTION, "Keep-Alive");
        post.setHeader(HttpHeaders.TRANSFER_ENCODING, "chunked");
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("file", new InputStreamBody(new SizedInputStream(), "file"));
        post.setEntity(entity);
        HttpClient client = fedoraClient.getHttpClient();
        HttpResponse response = null;
        try {
            response = client.execute(post);
View Full Code Here

TOP

Related Classes of org.apache.http.entity.mime.content.InputStreamBody

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.