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);
       
        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

        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

        RequestBuilder rb = new RequestBuilder("http://localhost:9000");

        final MultipartEntity entity = new MultipartEntity();
        // Add Sling POST options
        entity.addPart("lang", new StringBody("esp"));
        entity.addPart("code", new InputStreamBody(getClass().getResourceAsStream("/test.js"), "test.js"));
        executor.execute(
                rb.buildPostRequest("/system/console/scriptconsole.json")
                 .withEntity(entity)
                 .withCredentials("admin","admin")
            ).assertStatus(200);
View Full Code Here

                String value = entry.getValue();
                reqEntity.addPart(key, new StringBody(value, utf8));
            }
        }
        if (ins != null) {
            ContentBody contentBody = new InputStreamBody(ins, fileName);
            reqEntity.addPart(fileName, contentBody);
        }
        httppost.setEntity(reqEntity);
        HttpResponse response = getRequestExecutor().execute(
            getRequestBuilder().buildOtherRequest(httppost).withCredentials(
View Full Code Here

                  if(contentType==null) {
                    contentType = "application/octet-stream"; // default
                  }
                  String contentName = content.getName();
                  parts.add(new FormBodyPart(contentName,
                       new InputStreamBody(
                           content.getStream(),
                           contentType,
                           content.getName())));
                }
              }
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

        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

        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

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.