Examples of MultipartInputStream


Examples of nexj.core.util.MultipartInputStream

      {
         return;
      }
     
      byte[] buf = null;
      MultipartInputStream multipartStream = new MultipartInputStream(requestInputStream, sSeparator.getBytes(sEncoding),
         sEncoding);
     
      while (multipartStream.nextPart())
      {
         MIMEHeader header = multipartStream.getHeaders().find("Content-Disposition");

         if (header == null)
         {
            continue;
         }

         MIMEHeader.Value value = header.getFirstValue();

         if (value == null || !value.getName().equals("form-data") && !value.getName().equals("attachment"))
         {
            continue;
         }

         String sName = value.findArg("name");

         if (sName == null)
         {
            continue;
         }

         String sFileName = getFilenameForUpload(header);
        
         header = multipartStream.getHeaders().find("Content-Type");

         if (header != null && header.getFirstValue() != null && header.getFirstValue().getName().startsWith("multipart/"))
         {
            throw new MultipartDataException("Multiple files per input are not supported");
         }
View Full Code Here

Examples of org.apache.abdera.protocol.server.multipart.MultipartInputStream

            RequestContext request, InputStream requestData)
            throws IOException, ParseException, MessagingException {

        // NOTE: because request.getInputStream() has already been read
        // we pass in a seperate input stream containing the request data
        MultipartInputStream stream = getMultipartStream(request, requestData);
        List<MultipartRelatedPost> result = new LinkedList<MultipartRelatedPost>();
        stream.skipBoundary();

        String start = request.getContentType().getParameter(START_PARAM);

        Document<Source> source = null;
        Map<String, String> entryHeaders = new HashMap<String, String>();
        InputStream data = null;
        Map<String, String> dataHeaders = new HashMap<String, String>();

        Map<String, String> headers = getHeaders(stream);

        // first part is required to be the feed or entry
        if (start == null
                || start.length() == 0
                || (headers.containsKey(CONTENT_ID_HEADER) && start
                        .equals(headers.get(CONTENT_ID_HEADER)))
                || (headers.containsKey(CONTENT_TYPE_HEADER) && MimeTypeHelper
                        .isAtom(headers.get(CONTENT_TYPE_HEADER)))) {
            source = getEntry(stream, request);
            entryHeaders.putAll(headers);
        } else {
            throw new ParseException("First part was not a feed or entry: "
                    + headers);
            // data = getDataInputStream(multipart);
            // dataHeaders.putAll(headers);
        }

        try {
            while (stream.available() > 0) {
                stream.skipBoundary();
                headers = getHeaders(stream);
                if (start != null
                        && (headers.containsKey(CONTENT_ID_HEADER) && start
                                .equals(headers.get(CONTENT_ID_HEADER)))
                        && (headers.containsKey(CONTENT_TYPE_HEADER) && MimeTypeHelper
View Full Code Here

Examples of org.apache.abdera.protocol.server.multipart.MultipartInputStream

        PushbackInputStream pushBackInput = new PushbackInputStream(
                inputStream, 2);
        pushBackInput.unread("\r\n".getBytes());

        return new MultipartInputStream(pushBackInput, boundary.getBytes());
    }
View Full Code Here

Examples of org.mule.transport.http.multipart.MultiPartInputStream

    {
        Object body = null;

        if (httpRequest.getContentType().contains("multipart/form-data"))
        {
            MultiPartInputStream in = new MultiPartInputStream(httpRequest.getBody(), httpRequest.getContentType(), null);

            //We need to store this so that the headers for the part can be read
            parts = in.getParts();
            for (Part part : parts)
            {
                if (part.getName().equals("payload"))
                {
                    body = part.getInputStream();
View Full Code Here

Examples of org.mule.transport.http.multipart.MultiPartInputStream

    {
        Object body = null;

        if (httpRequest.getContentType().contains("multipart/form-data"))
        {
            MultiPartInputStream in = new MultiPartInputStream(httpRequest.getBody(), httpRequest.getContentType(), null);

            // We need to store this so that the headers for the part can be read
            parts = in.getParts();
            for (Part part : parts)
            {
                if (part.getName().equals("payload"))
                {
                    body = part.getInputStream();
View Full Code Here

Examples of org.nutz.mock.servlet.multipart.MultipartInputStream

    public static ServletInputStream ins(String path) {
      return ins(Streams.fileIn(path));
    }

    public static MultipartInputStream insmulti(String charset, String boundary) {
      return new MultipartInputStream(charset, boundary);
    }
View Full Code Here

Examples of org.nutz.mock.servlet.multipart.MultipartInputStream

              "------NutzMockHTTPBoundary@"
                  + Long.toHexString(System.currentTimeMillis()));
    }

    public static MultipartInputStream insmulti(String charset, File... files) {
      MultipartInputStream ins = insmulti(charset);
      for (int i = 0; i < files.length; i++) {
        if (files[i].isFile())
          ins.append("F" + i, files[i]);
      }
      return ins;
    }
View Full Code Here

Examples of org.nutz.mock.servlet.multipart.MultipartInputStream

    public void test_limit_file_content_type_fail() throws UploadException {
        MockHttpServletRequest req = Mock.servlet.request();
        req.setPathInfo("/nutz/junit/uploading");
        File blue = Files.findFile("org/nutz/mvc/upload/files/quick/blue.png");

        MultipartInputStream ins = Mock.servlet.insmulti(charset);
        ins.append("blue", blue);
        req.setInputStream(ins);
        req.init();

        /*
         * 文件超大,会限制
 
View Full Code Here

Examples of org.nutz.mock.servlet.multipart.MultipartInputStream

    public void test_limit_file_name_fail() throws UploadException {
        MockHttpServletRequest req = Mock.servlet.request();
        req.setPathInfo("/nutz/junit/uploading");
        File blue = Files.findFile("org/nutz/mvc/upload/files/quick/blue.png");

        MultipartInputStream ins = Mock.servlet.insmulti(charset);
        ins.append("blue", blue);
        req.setInputStream(ins);
        req.init();

        /*
         * 文件超大,会限制
 
View Full Code Here

Examples of org.nutz.mock.servlet.multipart.MultipartInputStream

    public void test_limit_file_size_ok() throws UploadException {
        MockHttpServletRequest req = Mock.servlet.request();
        req.setPathInfo("/nutz/junit/uploading");
        File blue = Files.findFile("org/nutz/mvc/upload/files/quick/blue.png");

        MultipartInputStream ins = Mock.servlet.insmulti(charset);
        ins.append("blue", blue);
        req.setInputStream(ins);
        req.init();

        /*
         * 文件超大,会限制
 
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.