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

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


                }
            }

            if (isMultipart) {
                for (final ContentStream content : streams) {
                  parts.put(content.getName(), new InputStreamBody(content.getStream(), content.getContentType(), null));
                }
            }

            try {
                result = client.POSTbytes(url, parts, true);
View Full Code Here


  }

  @Override
  public Promise<Void> addAttachment(final URI attachmentsUri, final InputStream inputStream, final String filename) {
    final MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.defaultCharset());
    entity.addPart(FILE_BODY_TYPE, new InputStreamBody(inputStream, filename));
    return postAttachments(attachmentsUri, entity);
  }
View Full Code Here

  @Override
  public Promise<Void> addAttachments(final URI attachmentsUri, final AttachmentInput... attachments) {
    final MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.defaultCharset());
    for (final AttachmentInput attachmentInput : attachments) {
      entity.addPart(FILE_BODY_TYPE, new InputStreamBody(attachmentInput.getInputStream(), attachmentInput.getFilename()));
    }
    return postAttachments(attachmentsUri, entity);
  }
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

        final FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        final FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
        final HttpStrictMultipart multipart = new HttpStrictMultipart("form-data", null, "foo",
                Arrays.asList(p1, p2));

        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        multipart.writeTo(out);
View Full Code Here

        final FormBodyPart p2 = new FormBodyPart(
                "field2",
                new FileBody(tmpfile, ContentType.create("text/plain", "ANSI_X3.4-1968"), "test-file"));
        final FormBodyPart p3 = new FormBodyPart(
                "field3",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
        final HttpStrictMultipart multipart = new HttpStrictMultipart("form-data", null, "foo",
                Arrays.asList(p1, p2, p3));

        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        multipart.writeTo(out);
View Full Code Here

        final FormBodyPart p2 = new FormBodyPart(
                "field2",
                new FileBody(tmpfile, ContentType.create("text/plain", "ANSI_X3.4-1968"), "test-file"));
        final FormBodyPart p3 = new FormBodyPart(
                "field3",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
        final HttpRFC6532Multipart multipart = new HttpRFC6532Multipart("form-data", null, "foo",
                Arrays.asList(p1, p2, p3));

        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        multipart.writeTo(out);
View Full Code Here

            writer.close();
        }

        final FormBodyPart p1 = new FormBodyPart(
                "field1",
                new InputStreamBody(new FileInputStream(tmpfile), s1 + ".tmp"));
        final FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), s2 + ".tmp"));
        final HttpBrowserCompatibleMultipart multipart = new HttpBrowserCompatibleMultipart(
                "form-data", Consts.UTF_8, "foo",
                Arrays.asList(p1, p2));

        final ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

  private void testUploadFile(String serverUrl) throws Exception {
    String requestUrl = UrlUtils.concat(serverUrl, FILES_ENDPOINT_PATH);
    HttpPost uploadFileRequest = new HttpPost(UrlUtils.concat(requestUrl, "/uploads"));

    MultipartEntity multipartEntity = new MultipartEntity();
    multipartEntity.addPart(requestUrl, new InputStreamBody(getClass().getResourceAsStream(imageFile), mimetypeGerman, "de.jpg"));
    multipartEntity.addPart("language", new StringBody("de"));
    uploadFileRequest.setEntity(multipartEntity);

    logger.debug("Creating new file at path {}", uploadFileRequest.getURI());
    DefaultHttpClient httpClient = new DefaultHttpClient();
View Full Code Here

   */
  private void testUploadFileByPath(String serverUrl) throws Exception {
    String requestUrl = UrlUtils.concat(serverUrl, FILES_ENDPOINT_PATH);
    HttpPost uploadFileRequest = new HttpPost(UrlUtils.concat(requestUrl, "/uploads"));
    MultipartEntity multipartEntity = new MultipartEntity();
    multipartEntity.addPart(requestUrl, new InputStreamBody(getClass().getResourceAsStream(imageFile), mimetypeGerman, "de.jpg"));
    multipartEntity.addPart("language", new StringBody("de"));
    multipartEntity.addPart("path", new StringBody(filePath));
    multipartEntity.addPart("mimeType", new StringBody("image/png"));
    uploadFileRequest.setEntity(multipartEntity);
    logger.debug("Uploading file at path {}", uploadFileRequest.getURI());
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.