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

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


            writer.close();
        }

        final FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        @SuppressWarnings("resource")
        final FormBodyPart p2 = new FormBodyPart(
                "field2",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
        final HttpStrictMultipart multipart = new HttpStrictMultipart("form-data", null, "foo",
View Full Code Here


            writer.close();
        }

        final FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        final FormBodyPart p2 = new FormBodyPart(
                "field2",
                new FileBody(tmpfile, ContentType.create("text/plain", "ANSI_X3.4-1968"), "test-file"));
        @SuppressWarnings("resource")
        final FormBodyPart p3 = new FormBodyPart(
                "field3",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
        final HttpStrictMultipart multipart = new HttpStrictMultipart("form-data", null, "foo",
View Full Code Here

            writer.close();
        }

        final FormBodyPart p1 = new FormBodyPart(
                "field1\u0414",
                new FileBody(tmpfile));
        final FormBodyPart p2 = new FormBodyPart(
                "field2",
                new FileBody(tmpfile, ContentType.create("text/plain", "ANSI_X3.4-1968"), "test-file"));
        @SuppressWarnings("resource")
        final FormBodyPart p3 = new FormBodyPart(
                "field3",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));
        final HttpRFC6532Multipart multipart = new HttpRFC6532Multipart("form-data", null, "foo",
View Full Code Here

    multipartEntity.addPart("r", new StringBody(repositoryId));
    multipartEntity.addPart("e", new StringBody(fixedExtension));
    multipartEntity.addPart("c", new StringBody(fixedClassifier));
    multipartEntity.addPart("hasPom", new StringBody(Boolean.TRUE.toString()));
    multipartEntity.addPart(pomFile.getName(), new FileBody(pomFile));
    multipartEntity.addPart(fileToDeploy.getName(), new FileBody(fileToDeploy));

    filePost.setEntity(multipartEntity);

    LOG.debug("URL:  " + restServiceURL);
    LOG.debug("Method: Post");
View Full Code Here

    filePost.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
    final MultipartEntity multipartEntity = new MultipartEntity();

    multipartEntity.addPart("r", new StringBody(repositoryId));
    multipartEntity.addPart("hasPom", new StringBody(Boolean.TRUE.toString()));
    multipartEntity.addPart(pomFile.getName(), new FileBody(pomFile));

    filePost.setEntity(multipartEntity);

    LOG.debug("URL:  " + filePost.getURI());
    LOG.debug("Method: Post");
View Full Code Here

    multipartEntity.addPart("g", new StringBody(groupId));
    multipartEntity.addPart("a", new StringBody(artifactId));
    multipartEntity.addPart("v", new StringBody(version));
    multipartEntity.addPart("p", new StringBody(extension == null ? "" : extension));
    multipartEntity.addPart("c", new StringBody(classifier == null ? "" : classifier));
    multipartEntity.addPart(fileToDeploy.getName(), new FileBody(fileToDeploy));

    filePost.setEntity(multipartEntity);

    return nexusRestClient.executeHTTPClientMethod(filePost).getStatusLine().getStatusCode();
  }
View Full Code Here

        public static void postFile(String fileName)
                        throws ClientProtocolException, IOException {
                HttpClient client = new DefaultHttpClient();
                HttpPost post = new HttpPost("http://10.1.1.204:1337");
                MultipartEntity entity = new MultipartEntity();
                entity.addPart("file", new FileBody(new File(fileName)));
                post.setEntity(entity);
                HttpResponse response = client.execute(post);

        }
View Full Code Here

    public static void postFile(String fileName, String mhttpgw)
        throws ClientProtocolException, IOException {
      HttpClient client = new DefaultHttpClient();
      HttpPost post = new HttpPost(mhttpgw);
      MultipartEntity entity = new MultipartEntity();
      entity.addPart("file", new FileBody(new File(fileName)));
      post.setEntity(entity);
      HttpResponse response = client.execute(post);

    }
View Full Code Here

            byte[] buf = IOUtils.toByteArray(new FileInputStream(file));
            MediaType mediaType = mimeTypes.
                    detect(new ByteArrayInputStream(buf), new Metadata());
            MimeType mimeType = mimeTypes.forName(mediaType.toString());
            FileBody fb = new FileBody(file, name + mimeType.getExtension(),
                    mimeType.getName(), Consts.UTF_8.name());

            multipartEntity.addPart("files[" + x + "]", fb);
            x++;
        }
View Full Code Here

        public static void postFile(String fileName)
                        throws ClientProtocolException, IOException {
                HttpClient client = new DefaultHttpClient();
                HttpPost post = new HttpPost("http://10.1.1.200:1337");
                MultipartEntity entity = new MultipartEntity();
                entity.addPart("file", new FileBody(new File(fileName)));
                post.setEntity(entity);
                HttpResponse response = client.execute(post);

        }
View Full Code Here

TOP

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

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.