Examples of bodyPart()


Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

  public static ClientResponse addPhoto(WebResource resource, String filename, String auth) {
    File file = new File(filename);

    FormDataMultiPart form = new FormDataMultiPart();
    form.bodyPart(new FormDataBodyPart("csrf", "csrf"));
    form.bodyPart(new FileDataBodyPart("file", file));

    return resource
        .path("addphoto.jsp")
        .cookie(new Cookie(WebHelper.AUTH_COOKIE, auth, "/", "127.0.0.1", 1))
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

  public static ClientResponse addPhoto(WebResource resource, String filename, String auth) {
    File file = new File(filename);

    FormDataMultiPart form = new FormDataMultiPart();
    form.bodyPart(new FormDataBodyPart("csrf", "csrf"));
    form.bodyPart(new FileDataBodyPart("file", file));

    return resource
        .path("addphoto.jsp")
        .cookie(new Cookie(WebHelper.AUTH_COOKIE, auth, "/", "127.0.0.1", 1))
        .cookie(new Cookie(CSRFProtectionService.CSRF_COOKIE, "csrf"))
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

      try {
          InputStream deployment = archive.as(ZipExporter.class).exportAsInputStream();
         
          // Build up the POST form to send to Glassfish
          final FormDataMultiPart form = new FormDataMultiPart();
          form.bodyPart(new StreamDataBodyPart("id", deployment, archiveName));
         
          deploymentName = createDeploymentName(archiveName);
          addDeployFormFields(deploymentName, form);
         
          // Do Deploy the application on the remote GlassFish
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

      String description) throws UniformInterfaceException,
      ClientHandlerException, FileNotFoundException, ParseException,
      RequestException {
    FormDataMultiPart part = new FormDataMultiPart();
    if (description != null) {
      part.bodyPart(new FormDataBodyPart("description", description));
    }
    part.bodyPart(new FileDataBodyPart("file", file,
        MediaType.APPLICATION_OCTET_STREAM_TYPE));
    ClientResponse response = (ClientResponse) webResource
        .accept(MediaType.APPLICATION_XML)
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

      RequestException {
    FormDataMultiPart part = new FormDataMultiPart();
    if (description != null) {
      part.bodyPart(new FormDataBodyPart("description", description));
    }
    part.bodyPart(new FileDataBodyPart("file", file,
        MediaType.APPLICATION_OCTET_STREAM_TYPE));
    ClientResponse response = (ClientResponse) webResource
        .accept(MediaType.APPLICATION_XML)
        .type(Boundary.addBoundary(MediaType.MULTIPART_FORM_DATA_TYPE))
        .header("description", description)
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

      throw new AppThwackException("file cannot be a directory");
    }
   
    FormDataMultiPart form = new FormDataMultiPart();
    form.field("name", name);
    form.bodyPart(new FileDataBodyPart("file", file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
   
    return root.path("file").type(MediaType.MULTIPART_FORM_DATA).post(AppThwackFile.class, form);
  }
}
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

    public void testPart() {
        WebResource webResource = resource().path("form/part");

        FormDataMultiPart mp = new FormDataMultiPart();
        FormDataBodyPart p = new FormDataBodyPart(FormDataContentDisposition.name("part").build(), "CONTENT");
        mp.bodyPart(p);

        String s = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(String.class, mp);
        Assert.assertEquals("CONTENT", s);
    }
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

    public void testPartWithFileName() {
        WebResource webResource = resource().path("form/part-file-name");

        FormDataMultiPart mp = new FormDataMultiPart();
        FormDataBodyPart p = new FormDataBodyPart(FormDataContentDisposition.name("part").fileName("file").build(), "CONTENT");
        mp.bodyPart(p);

        String s = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(String.class, mp);
        Assert.assertEquals("CONTENT:file", s);
    }
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

    @Test
    public void testXmlJAXBPart() {
        WebResource webResource = resource().path("form/xml-jaxb-part");

        FormDataMultiPart mp = new FormDataMultiPart();
        mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("bean").fileName("bean").build(),
                new Bean("BEAN"),
                MediaType.APPLICATION_XML_TYPE));
        mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("string").fileName("string").build(),
                "STRING"));
View Full Code Here

Examples of com.sun.jersey.multipart.FormDataMultiPart.bodyPart()

        FormDataMultiPart mp = new FormDataMultiPart();
        mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("bean").fileName("bean").build(),
                new Bean("BEAN"),
                MediaType.APPLICATION_XML_TYPE));
        mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("string").fileName("string").build(),
                "STRING"));

        String s = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(String.class, mp);
        Assert.assertEquals("STRING:string,BEAN:bean", s);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.