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

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


        HttpClient httpclient = new DefaultHttpClient();

        HttpPost httppost = new HttpPost("http://localhost:8080" +
                "/servlets-examples/servlet/RequestInfoExample");

        FileBody bin = new FileBody(new File(args[0]));
        StringBody comment = new StringBody("A binary file of some kind");

        MultipartEntity reqEntity = new MultipartEntity();
        reqEntity.addPart("bin", bin);
        reqEntity.addPart("comment", comment);
View Full Code Here


    if (file instanceof String && !((String) file).matches("https?:.*|s3:.*|data:[^;]*;base64,([a-zA-Z0-9/+\n=]+)")) {
      file = new File((String) file);
    }
    if (file instanceof File) {
      multipart.addPart("file", new FileBody((File) file));
    } else if (file instanceof String) {
      multipart.addPart("file", new StringBody((String) file));
        } else if (file instanceof byte[]) {
            multipart.addPart("file", new ByteArrayBody((byte[]) file, "file"));
    } else if (file == null) {
View Full Code Here

    if (file instanceof String && !((String) file).matches("^https?:.*")) {
      file = new File((String) file);
    }
    if (file instanceof File) {
      multipart.addPart("file", new FileBody((File) file));
    } else if (file instanceof String) {
      multipart.addPart("file", new StringBody((String) file));
    }
    postMethod.setEntity(multipart);

View Full Code Here

        };
        return uploadContentBody(url, field, contentBody);
    }

    public JsonObject uploadFile(String url, String field, File file) throws IOException {
        ContentBody contentBody = new FileBody(file, "multipart/form-data");
        return uploadContentBody(url, field, contentBody);
    }
View Full Code Here

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

        }

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

        multipart.addBodyPart(p1);
View Full Code Here

        }

        HttpMultipart multipart = new HttpMultipart("form-data", "foo");
        FormBodyPart p1 = new FormBodyPart(
                "field1",
                new FileBody(tmpfile));
        FormBodyPart p2 = new FormBodyPart(
                "field2",
                new FileBody(tmpfile, "test-file", "text/plain", "ANSI_X3.4-1968"));
        FormBodyPart p3 = new FormBodyPart(
                "field3",
                new InputStreamBody(new FileInputStream(tmpfile), "file.tmp"));

        multipart.addBodyPart(p1);
View Full Code Here

      HttpPost post = new HttpPost("https://rink.hockeyapp.net/api/2/apps");
      MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
     
      // Set headers and parameters
      post.addHeader("X-HockeyAppToken", properties.get("hockeyAppToken"));
      entity.addPart("ipa", new FileBody(
          new File(appPath + "/" + properties.get("appName") + ".ipa"),
              "application/zip"));
      entity.addPart("dsym", new FileBody(
          new File(appPath + "/" + properties.get("appName") + ".dSYM.zip"),
          "application/zip"));     
      entity.addPart("notes",
          new StringBody(properties.get("releaseNotes"),
              "text/plain", Charset.forName("UTF-8")));     
View Full Code Here

        assertTrue(file.canRead());
    }

    @Before
    public void setupMultipart() {
        FileBody bin = new FileBody(file);
        multiPart = new MultipartEntity();
        multiPart.addPart(fileParam, bin);
    }
View Full Code Here

    }
   
    @Test
    public void testPostMultipartConsistency409() throws Exception{
     
        FileBody bin = new FileBody(new File(URI.create(inconsistentFileName)));
        MultipartEntity incMultiPart = new MultipartEntity();
        incMultiPart.addPart(fileParam, bin);

      String[] services = {"/owl","/owlmini"};
  
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.