Examples of MultipartParser


Examples of com.oreilly.servlet.multipart.MultipartParser

    savedir = saveDirectory;

    // Parse the incoming multipart, storing files in the dir provided,
    // and populate the meta objects which describe what we found
    MultipartParser parser = new MultipartParser(request, maxPostSize, true, true, encoding);

    // Some people like to fetch query string parameters from
    // MultipartRequest, so here we make that possible.  Thanks to
    // Ben Johnson, ben.johnson@merrillcorp.com, for the idea.
    if (request.getQueryString() != null) {
      // Let HttpUtils create a name->String[] structure
      Hashtable queryParameters =
        HttpUtils.parseQueryString(request.getQueryString());
      // For our own use, name it a name->Vector structure
      Enumeration queryParameterNames = queryParameters.keys();
      while (queryParameterNames.hasMoreElements()) {
        Object paramName = queryParameterNames.nextElement();
        String[] values = (String[])queryParameters.get(paramName);
        Vector newValues = new Vector();
        for (int i = 0; i < values.length; i++) {
          newValues.add(values[i]);
        }
        parameters.put(paramName, newValues);
      }
    }

    Part part;
    while ((part = parser.readNextPart()) != null) {
      String name = part.getName();
      if (part.isParam()) {
        // It's a parameter part, add it to the vector of values
        ParamPart paramPart = (ParamPart) part;
        String value = paramPart.getStringValue();
View Full Code Here

Examples of com.oreilly.servlet.multipart.MultipartParser

            if (req.getContentType() != null
                    && req.getContentType().toUpperCase().
                    startsWith("MULTIPART/FORM-DATA")) {
                final int size = Integer.parseInt(WebMailServer.
                        getStorage().getConfig("max attach size"));
                final MultipartParser mparser = new MultipartParser(req, size);
                Part p;
                while ((p = mparser.readNextPart()) != null) {
                    if (p.isFile()) {
                        final ByteStore bs = ByteStore.getBinaryFromIS(
                                ((FilePart) p).getInputStream(), size);
                        bs.setName(((FilePart) p).getFileName());
                        bs.setContentType(getStorage().getMimeType(
View Full Code Here

Examples of com.oreilly.servlet.multipart.MultipartParser

  private void processCalendarFileUpload(UserRequest ureq) {
    // upload the file
    try {
      // don't worry about NullPointerExceptions.
      // we'll catch exceptions if any operation fails.
      MultipartParser mpp = new MultipartParser(ureq.getHttpReq(), (int) fileUploadLimit * 1024);
      mpp.setEncoding("UTF-8");
      Part part;
      boolean fileWritten = false;
      while ((part = mpp.readNextPart()) != null) {
        if (part.isFile() && !fileWritten) {
          FilePart fPart = (FilePart) part;
          String type = fPart.getContentType();
          // get file contents
          Tracing.logWarn(type + fPart.getFileName(), this.getClass());
View Full Code Here

Examples of com.oreilly.servlet.multipart.MultipartParser

            // parse request body
            String contentType = source.getContentType();
            if (contentType != null && contentType.startsWith("multipart/form-data") && !isPortletRequest) {
                com.oreilly.servlet.multipart.Part attachmentPart;
                try {
                    MultipartParser multi = new MultipartParser(source, source.getContentLength(), true, true, "UTF-8");
                    boolean noAttachments = source.getContentLength() > sizeLimit;
                   
                    while ((attachmentPart = multi.readNextPart()) != null) {
                        String partName = attachmentPart.getName();

                        if (attachmentPart.isParam()) {
                            ParamPart parameterPart = (ParamPart)attachmentPart;
                            String paramValue = parameterPart.getStringValue();
View Full Code Here

Examples of com.oreilly.servlet.multipart.MultipartParser

    // case user not use httpclient MultPart Method upload file, but use url
    // and query
    // parameters( /ul?fcontent=xxx)
    try {
      // Max file size = 1GB
      MultipartParser mp = new MultipartParser(request,
          1024 * 1024 * 1024, false, false, "gbk");
      System.out
          .println("The file is uploaded by httpclient multiple part method.");
      Part part;
      while ((part = mp.readNextPart()) != null) {
        String name = part.getName();
        if (part.isParam()) {
          ParamPart paramPart = (ParamPart) part;
          String value = paramPart.getStringValue();
          // System.out.println("param: name=" + name + "; value=" +
View Full Code Here

Examples of com.oreilly.servlet.multipart.MultipartParser

     * @throws IOException
     */
    protected void receiveMultipart(HttpServletRequest request, HttpServletResponse response, HashMap<String, Object> params) throws IOException {
        ArrayList<FileApi.FileInfo> files = new ArrayList<FileApi.FileInfo>();
       
    MultipartParser parser = new MultipartParser(request, Integer.MAX_VALUE, true, true, null);
    FileApi api = getFileApi();
    Part part;
    while ((part = parser.readNextPart()) != null) {
      String name = part.getName();
     
      if (part.isParam()) {
        ParamPart paramPart = (ParamPart) part;
        Object value = paramPart.getStringValue();
View Full Code Here

Examples of com.oreilly.servlet.multipart.MultipartParser

    }

    private void processMultiPart(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        PrintWriter out = resp.getWriter();
        resp.setContentType("text/plain");
        MultipartParser mp = new MultipartParser(req, 2048);
        Part part = null;
        while ((part = mp.readNextPart()) != null) {
            String name = part.getName().trim();
            if (part.isParam()) {
                // it's a parameter part
                ParamPart paramPart = (ParamPart) part;
                String value = paramPart.getStringValue().trim();
View Full Code Here

Examples of org.apache.chemistry.opencmis.server.impl.browser.MultipartParser

                + boundary + "\r\n"
                + "Content-Disposition: form-data; name=\"content\"; filename=test-filename.txt\r\n"
                + "Content-Type: text/plain\r\n" + "Content-Transfer-Encoding: binary\r\n" + "\r\n"
                + new String(content) + "\r\n" + "--" + boundary + "--").getBytes("ISO-8859-1");

        MultipartParser parser = prepareParser(boundary, formdata);

        Map<String, String> values = new HashMap<String, String>();
        values.put("field1", "value1");
        values.put("field2", "value2");
        values.put("field3", "value3");
View Full Code Here

Examples of org.apache.chemistry.opencmis.server.impl.browser.MultipartParser

                + boundary + "\r\nContent-Disposition: form-data; name=\"propertyValue[1]\"\r\n\r\ncmis:document\r\n--"
                + boundary
                + "\r\nContent-Disposition: form-data; name=\"token\"\r\n\r\n855475d8a6169b5f57111f5921f56136\r\n--"
                + boundary + "--").getBytes("ISO-8859-1");

        MultipartParser parser = prepareParser(boundary, formdata);

        Map<String, String> values = new HashMap<String, String>();
        values.put("fileUploader-data", "");
        values.put("objectid", "f6bad54b4696bf2ac9249805");
        values.put("cmisaction", "createDocument");
View Full Code Here

Examples of org.apache.chemistry.opencmis.server.impl.browser.MultipartParser

    public void testNoPreamble() throws Exception {
        String boundary = "BoUnDaRy--987654320";
        byte[] formdata = ("--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"field1\"\r\n" + "\r\n"
                + "value1\r\n" + "--" + boundary + "--").getBytes();

        MultipartParser parser = prepareParser(boundary, formdata);

        Map<String, String> values = new HashMap<String, String>();
        values.put("field1", "value1");

        assertMultipartBasics(parser, 1, values, false, null, null, 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.