Examples of MultipartBody


Examples of com.mashape.unirest.request.body.MultipartBody

  public HttpRequestWithBody queryString(String name, Object value) {
    return (HttpRequestWithBody) super.queryString(name, value);
  }

  public MultipartBody field(String name, Object value) {
    MultipartBody body = new MultipartBody(this).field(name, (value == null) ? "" : value.toString());
    this.body = body;
    return body;
  }
View Full Code Here

Examples of com.ning.http.multipart.MultipartBody

                         * TODO: AHC-78: SSL + zero copy isn't supported by the MultiPart class and pretty complex to implements.
                         */
                        if (future.getRequest().getParts() != null) {
                            String boundary = future.getNettyRequest().getHeader("Content-Type");
                            String length = future.getNettyRequest().getHeader("Content-Length");
                            body = new MultipartBody(future.getRequest().getParts(), boundary, length);
                        }

                        ChannelFuture writeFuture;
                        if (channel.getPipeline().get(SslHandler.class) == null && (body instanceof RandomAccessBody)) {
                            BodyFileRegion bodyFileRegion = new BodyFileRegion((RandomAccessBody) body);
View Full Code Here

Examples of org.apache.clerezza.jaxrs.utils.form.MultiPartBody

    InputStream entityStream = new ByteArrayInputStream(message);
   
    MultiPartFormMessageBodyReader multiPartFormMBR = new MultiPartFormMessageBodyReader();
    MediaType mediaType = MediaType.valueOf("multipart/form-data; boundary=AaB03x");
   
    MultiPartBody multiPartBody = multiPartFormMBR.readFrom(null, null, null, mediaType, null, entityStream);
   
    String[] paramNames = multiPartBody.getParameterNames();
    String[] expectedParamNames = {paramName1, paramName2, paramName3};
    System.out.println(Arrays.toString(paramNames));
    Assert.assertArrayEquals(expectedParamNames, paramNames);
    Assert.assertEquals(field1Value, multiPartBody.getParameteValues(paramName1)[0].toString());
    Assert.assertEquals(field2Value, multiPartBody.getParameteValues(paramName2)[0].toString());
   
    String[] fileParamNames = multiPartBody.getFileParameterNames();     
    String[] expectedFileParamNames = {paramName3};
    Assert.assertArrayEquals(expectedFileParamNames, fileParamNames);
    FormFile[] formFiles = multiPartBody.getFormFileParameterValues(paramName3);
    Assert.assertArrayEquals(binaryData.getBytes(), formFiles[0].getContent());
    Assert.assertEquals(MediaType.valueOf(binaryMimeType), formFiles[0].getMediaType());
    Assert.assertEquals(binaryFilename, formFiles[0].getFileName());
  }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

                HttpServletRequest request = (HttpServletRequest)m.get(AbstractHTTPDestination.HTTP_REQUEST);
                FormUtils.populateMapFromString(params, (String)body, decode, request);
            } else {
                if (mt != null && "multipart".equalsIgnoreCase(mt.getType())
                    && MediaType.MULTIPART_FORM_DATA_TYPE.isCompatible(mt)) {
                    MultipartBody body = AttachmentUtils.getMultipartBody(mc);
                    FormUtils.populateMapFromMultipart(params, body, decode);
                } else {
                    org.apache.cxf.common.i18n.Message errorMsg =
                        new org.apache.cxf.common.i18n.Message("WRONG_FORM_MEDIA_TYPE",
                                                               BUNDLE,
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

        client.type("multipart/form-data").accept("multipart/form-data");
       
        ContentDisposition cd = new ContentDisposition("attachment;filename=java.jpg");
        Attachment att = new Attachment("image", is1, cd);
       
        MultipartBody body = new MultipartBody(att);
        MultipartBody body2 = client.post(body, MultipartBody.class);
        InputStream is2 = body2.getRootAttachment().getDataHandler().getInputStream();
        byte[] image1 = IOUtils.readBytesFromStream(
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
        byte[] image2 = IOUtils.readBytesFromStream(is2);
        assertTrue(Arrays.equals(image1, image2));
        ContentDisposition cd2 = body2.getRootAttachment().getContentDisposition();
        assertEquals("attachment;filename=java.jpg", cd2.toString());
        assertEquals("java.jpg", cd2.getParameter("filename"));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        client.type("multipart/form-data").accept("multipart/form-data");
       
        MultipartBody body2 = client.post(file, MultipartBody.class);
        InputStream is2 = body2.getRootAttachment().getDataHandler().getInputStream();
        byte[] image1 = IOUtils.readBytesFromStream(
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
        byte[] image2 = IOUtils.readBytesFromStream(is2);
        assertTrue(Arrays.equals(image1, image2));
        ContentDisposition cd2 = body2.getRootAttachment().getContentDisposition();
        assertEquals("attachment;filename=java.jpg", cd2.toString());
        assertEquals("java.jpg", cd2.getParameter("filename"));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

            throw new WebApplicationException();
        }
        headers.putSingle("Content-Location", "http://host/location");
        newAtts.add(new Attachment(at.getContentId(), at.getDataHandler(), headers));
       
        return new MultipartBody(newAtts);
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

        headers.putSingle("Content-Disposition", cd.toString());
        headers.putSingle("Content-Location", "http://host/bar");
        headers.putSingle("custom-header", "custom");
        Attachment att = new Attachment(is1, headers);
       
        MultipartBody body = new MultipartBody(att);
        MultipartBody body2 = client.post(body, MultipartBody.class);
        InputStream is2 = body2.getRootAttachment().getDataHandler().getInputStream();
        byte[] image1 = IOUtils.readBytesFromStream(
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
        byte[] image2 = IOUtils.readBytesFromStream(is2);
        assertTrue(Arrays.equals(image1, image2));
        ContentDisposition cd2 = body2.getRootAttachment().getContentDisposition();
        assertEquals("attachment;filename=java.jpg", cd2.toString());
        assertEquals("java.jpg", cd2.getParameter("filename"));
        assertEquals("http://host/location", body2.getRootAttachment().getHeader("Content-Location"));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

        HTTPConduit conduit = WebClient.getConfig(client).getHttpConduit();
        conduit.getClient().setReceiveTimeout(1000000);
        conduit.getClient().setConnectionTimeout(1000000);
        client.type("multipart/form-data").accept("multipart/form-data");
       
        MultipartBody body2 = client.post(file, MultipartBody.class);
        InputStream is2 = body2.getRootAttachment().getDataHandler().getInputStream();
        byte[] image1 = IOUtils.readBytesFromStream(
            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg"));
        byte[] image2 = IOUtils.readBytesFromStream(is2);
        assertTrue(Arrays.equals(image1, image2));
        ContentDisposition cd2 = body2.getRootAttachment().getContentDisposition();
        assertEquals("form-data;name=file;filename=java.jpg", cd2.toString());
        assertEquals("java.jpg", cd2.getParameter("filename"));
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.ext.multipart.MultipartBody

                map.put(a.getContentType().toString(), fromAttachment(a, actual, actual, anns));
            }
            return map;
        }
        if (MultipartBody.class.isAssignableFrom(c)) {
            return new MultipartBody(infos);
        }
       
        Multipart id = AnnotationUtils.getAnnotation(anns, Multipart.class);
        Attachment multipart = AttachmentUtils.getMultipart(id, mt, infos);
        if (multipart != null) {
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.