Package com.oreilly.servlet

Examples of com.oreilly.servlet.MultipartRequest


                    throw new RuntimeException("Failed to create directory " + workingDir.getAbsolutePath());
                }

                try
                {
                    MultipartRequest req = new MultipartRequest(request.raw(), workingDir.getAbsolutePath());                   
                    String configString = makeConfigFileForJavaGrader(req, workingDir);
                    SimpleFileIO.writeStringToTextFile(configString, workingDir.getAbsolutePath() + File.separator + "config.txt");                   

                    //run automark
                    JavaGraderDriver agm = new JavaGraderDriver();
View Full Code Here


                    throw new RuntimeException("Failed to create directory " + workingDir.getAbsolutePath());
                }

                try
                {
                    MultipartRequest req = new MultipartRequest(request.raw(), workingDir.getAbsolutePath(), Integer.MAX_VALUE);                   
                    String configString = makeConfigFileForJavaGrader(req, workingDir);
                    SimpleFileIO.writeStringToTextFile(configString, workingDir.getAbsolutePath() + File.separator + "config.txt");                   

                    //run automark
                    JavaGraderDriver agm = new JavaGraderDriver();
View Full Code Here

            boolean mkdirs = dir.mkdirs();
            if (!mkdirs) {
              throw new IOException("can't create dir");
            }
        }
    MultipartRequest multi =
      new MultipartRequest(
        request,
        uploadDir ,
        10 * 1024 * 1024);
    File file = null;
    Enumeration files = multi.getFileNames();
    while (files.hasMoreElements()) {
      String name = (String) files.nextElement();
      file = multi.getFile(name);
    }
    if (file == null) {
      throw new IOException("no file");
    }
    return file;
View Full Code Here

        }
       
        // MultipartRequest�� ���ڵ��� ������ ��� �ϱ� ������ request�� ���ڵ��� �̾Ƽ� �־�����մϴ�.
        String encoding = CommonUtil.nchk(req.getCharacterEncoding(), "euc-kr");
       
    MultipartRequest multi =
      new MultipartRequest(
        req,
        uploadDir,
        200 * 1024 * 1024,
        encoding);
    // 200MB
    ArrayList<DownFile> arrdf = new ArrayList<DownFile>();
    Article article = null;
    long sid = CommonUtil.getCookieLong(req, "sid");
    try {
      int seq = 0, ref = 0, lev = 0, step = 0;
      String writer = multi.getParameter("writer");
      String bbs = multi.getParameter("bbs");
      String content = multi.getParameter("content");
      String email = multi.getParameter("email");
      String subject = multi.getParameter("subject");
      String homepage = multi.getParameter("homepage");
      String password = multi.getParameter("password");
      String html = multi.getParameter("html");
      String ccl_id = multi.getParameter("ccl_id");
      String ip = req.getRemoteAddr();
     
      //id
        boolean isLogin = sid > 0 && !"".equals(writer);
        if (!isLogin) {
            res.sendRedirect(Navigation.getPath("LOGFORM"));
            return null;
        }
// Multipart �� ���� ������ 8859_1�� ���� ��.��
      article =
        new Article(
          bbs,
          seq,
          ref,
          step,
          lev,
          null,
          sid,
          writer,
          subject,
          content,
          password,
          email,
          homepage,
          0,
          null,
          html,
          ip, ccl_id);

      int cnt = 0;
      Enumeration<String> files = multi.getFileNames();
      while (files.hasMoreElements()) {
        String name = files.nextElement();
        File f = multi.getFile(name);
        if (f != null) {
          arrdf.add(new DownFile(f, cnt++));
        }
      }
    } catch (Exception e) {
      System.out.println("WriteServlet:" + CommonUtil.a2k(e.toString()));
    }

    if (hasNothing(article)) {
      throw new SecurityException("no content");
    } else if (Spam.checkContent(article)) {
      throw new SecurityException("rejected");
    }
   
    /*
      db �Է�
    */
    DbCon dbCon = new DbCon();
    Connection conn = null;
    ArticleDao articleDao = new ArticleDao();
   
    String act = multi.getParameter("act");
   
    try {

      conn = dbCon.getConnection();
      conn.setAutoCommit(false);

     
      String[] delFiles = null;

      int seq = 0;
      if ("MODIFY".equals(act)) {
        seq = Integer.parseInt(multi.getParameter("seq"));
        delFiles = multi.getParameterValues("delFile");
        article.setSeq(seq);
      }

      if ("REPLY".equals(act)) {
        article.setSeq(articleDao.getSeq(conn));
        article.setRef(Integer.parseInt(multi.getParameter("ref")));
        article.setLev(Integer.parseInt(multi.getParameter("lev")));
        article.setStep(
            Integer.parseInt(multi.getParameter("step")));
        articleDao.reply(conn, article);

      } else if ("MODIFY".equals(act)) {
        articleDao.modify(conn, article);
        articleDao.deleteFiles(conn, delFiles);
View Full Code Here

            }
       
            // Construct a MultipartRequest to help read the information.
            // Pass in the request, a directory to save files to, and the
            // maximum POST size we should attempt to handle.
            MultipartRequest multipartrequest =
                new MultipartRequest( request, stringWorkingDirectory, 5 * 1024 * 1024 );
           
            // Getting all file names from the request
            Enumeration files = multipartrequest.getFileNames();
           
            // Every received file will be converted to the specified type
            while (files.hasMoreElements()) {
                // Getting the name from the element
                String stringName = (String)files.nextElement();
       
                // Getting the filename from the request
                String stringFilename =
                    multipartrequest.getFilesystemName( stringName );
               
                // Converting the given file on the server to the specified type and
                // append a special extension
                File cleanupFile = null;
                String stringSourceFile = stringWorkingDirectory + stringFilename;
               
                try {
                    String stringConvertedFile = convertDocument(stringSourceFile,
                        multipartrequest.getParameter( "converttype" ),
                        multipartrequest.getParameter( "extension" ));
                   
                    String shortFileName = stringConvertedFile.substring(
                        stringConvertedFile.lastIndexOf('/') + 1);

                    // Set the response header
                    // Set the filename, is used when the file will be saved (problem with mozilla)
                    response.addHeader( "Content-Disposition",
                                        "attachment; filename=" + shortFileName);
               
                    // Constructing the multi part response to the client
                    MultipartResponse multipartresponse = new MultipartResponse(response);
               
                    // Is the convert type HTML?
                    if ( ( multipartrequest.getParameter( "converttype" ).equals(
                               "swriter: HTML (StarWriter)" ) )
                         || ( multipartrequest.getParameter( "converttype" ).equals(
                                  "scalc: HTML (StarCalc)" ) ) ) {
                        // Setting the content type of the response being sent to the client
                        // to text
                        multipartresponse.startResponse( "text/html" );
                    } else {
View Full Code Here

      }
       
      // Construct a MultipartRequest to help read the information.
      // Pass in the request, a directory to save files to, and the
      // maximum POST size we should attempt to handle.
      MultipartRequest multipartrequest =
      new MultipartRequest( request, stringWorkingDirectory, 5 * 1024 * 1024 );
     
      // Getting all file names from the request
      Enumeration files = multipartrequest.getFileNames();
     
      // Every received file will be converted to the specified type
      while (files.hasMoreElements()) {
        // Getting the name from the element
        String stringName = (String)files.nextElement();
       
        // Getting the filename from the request
        String stringFilename =
        multipartrequest.getFilesystemName( stringName );
       
        // Converting the given file on the server to the specified type and
        // append a special extension
        String stringConvertedFile = this.convertDocument(
        stringWorkingDirectory + stringFilename,
        multipartrequest.getParameter( "converttype" ),
        multipartrequest.getParameter( "extension" ) );

        // Constructing the multi part response to the client
        MultipartResponse multipartresponse = new MultipartResponse(
        response );
       
        // Is the convert type HTML?
        if ( ( multipartrequest.getParameter( "converttype" ).equals(
        "swriter: HTML (StarWriter)" ) )
        || ( multipartrequest.getParameter( "converttype" ).equals(
        "scalc: HTML (StarCalc)" ) ) ) {
          // Setting the content type of the response being sent to the client
          // to text
          multipartresponse.startResponse( "text/html" );
        } else {
View Full Code Here

                    }
                }
            };

            this.charset = request.getCharacterEncoding();
            this.multipart = new MultipartRequest(request,
                                                  tempDir.getAbsolutePath(),
                                                  (int) maxPostSize,
                                                  this.charset,
                                                  renamePolicy);
        }
View Full Code Here

TOP

Related Classes of com.oreilly.servlet.MultipartRequest

Copyright © 2018 www.massapicom. 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.