Examples of MultipartBody


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(c, id, mt, infos);
        if (multipart != null) {
View Full Code Here

Examples of org.asynchttpclient.multipart.MultipartBody

    }

    public boolean doHandle(final FilterChainContext ctx, final Request request, final HttpRequestPacket requestPacket) throws IOException {

        final List<Part> parts = request.getParts();
        final MultipartBody multipartBody = MultipartUtils.newMultipartBody(parts, request.getHeaders());
        requestPacket.setContentLengthLong(multipartBody.getContentLength());
        requestPacket.setContentType(multipartBody.getContentType());
        if (GrizzlyAsyncHttpProvider.LOGGER.isDebugEnabled()) {
            GrizzlyAsyncHttpProvider.LOGGER.debug("REQUEST(modified): contentLength={}, contentType={}",
                    new Object[] { requestPacket.getContentLength(), requestPacket.getContentType() });
        }
View Full Code Here

Examples of org.wymiwyg.rwcf.form.MultiPartBody

   */
 
  protected void setItemOrTopicProperties(Resource itemOrTopic, EnhancedRequest request)
      throws HandlerException {
    //get request body
    MultiPartBody requestBody = (MultiPartBody) request.getBody();
    // URL baseURL = new URL(target.getURI());
    URL baseURL = request.getRequestURLWithoutParams();
    String uri = requestBody.getParameter("uri");
    if (uri != null) {
      try {
        //try to create a new resource itemOrTopic
        itemOrTopic = model.createResource(new URL(baseURL, uri).toString());
      } catch (MalformedURLException e) {
        throw new HandlerException(e);
      }
    }
   
    //retrieve parameters from body:
   
    String language = requestBody.getParameter("language");
    String title = requestBody.getParameter("title");
    String summary = requestBody.getParameter("description");
    if (!"yes".equals(requestBody.getParameter("custom_summary"))) {
      summary = null;
    }
    String creator = requestBody.getParameter("creator");
    String date = requestBody.getParameter("date");
    String content = requestBody.getParameter("body");
   
    String[] permissions = requestBody.getParameterValues("permission");
    String[] maxShowInlineLength = requestBody.getParameterValues("maxShowInlineLength");
    if ((maxShowInlineLength != null) && (maxShowInlineLength.length > 0)) {
      Literal maxShowInlineLengthLiteral = model.createTypedLiteral(maxShowInlineLength[0], XSDDatatype.XSDdecimal);
      itemOrTopic.removeAll(KNOBOT.maxShowInlineLength);
      itemOrTopic.addProperty(KNOBOT.maxShowInlineLength, maxShowInlineLengthLiteral);
    }
    addPermissions(itemOrTopic, permissions);
    //shop
    boolean shop = "checked".equals(requestBody.getParameter("shop"));
    String priceString = requestBody.getParameter("price");
    String articleID = requestBody.getParameter("articleID");
    boolean commentable = "yes"
        .equals(requestBody.getParameter("comments"));
    float price = 0;
    if ((priceString != null) && (!priceString.equals(""))) {
      price = Float.parseFloat(priceString);
    }
   
    //custom shipping costs parameter (has to be float):
    String customShippingCostsString = requestBody.getParameter("customShippingCosts");
    String useDefaultShippingCosts = requestBody.getParameter("useShippingCosts");
    float customShippingCosts = 0;
    if ((customShippingCostsString != null) && (!customShippingCostsString.equals(""))) {
      customShippingCosts = Float.parseFloat(customShippingCostsString);
    }
   
View Full Code Here

Examples of org.wymiwyg.wrhapi.util.parameterparser.MultiPartBody

   * @see org.wymiwyg.wrhapi.Handler#handle(org.wymiwyg.wrhapi.Request,
   *      org.wymiwyg.wrhapi.Response)
   */
  public void handle(Request request, Response response)
      throws HandlerException {
    MultiPartBody body = ParameterUtil.parseMultipart(request);
    final FormFile formFile = body.getFormFileParameterValues("file")[0];
    final String locationString = body.getTextParameterValues("location")[0];
    final Model editableModel = ModelFactory.createDefaultModel();
    final Resource infoBitResource = editableModel.createResource();
   
    infoBitResource.addProperty(DISCOBITS.mediaType, formFile
        .getMimeType().toString());
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.