Package org.apache.commons.fileupload.servlet

Examples of org.apache.commons.fileupload.servlet.ServletFileUpload


 
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    //logger.info("File upload...");
    HttpSession session = request.getSession(true);
    ServletFileUpload upload = new ServletFileUpload();
    upload.setFileSizeMax(MAX_SIZE);
    upload.setHeaderEncoding("UTF-8");
    String message = null;
    Map<String, String> parameters = new HashMap<String, String>();
    List<UploadItem> uploadItems = new ArrayList<UploadItem>();
    try {
      FileItemIterator iter;
      try {
        iter = upload.getItemIterator(request);
        FileItemStream imageFileItem = null;
        String folder = null;
        InputStream stream = null;
        InputStream filestream = null;
        byte[] fileData = null;
View Full Code Here


    ServletOutputStream out = null;

    try {
      HttpRequestHolder.setServletRequest(request);
      FileItemFactory factory = new DiskFileItemFactory();
      ServletFileUpload upload = new ServletFileUpload(factory);

      List<FileItem> items = upload.parseRequest(request);
      response.setContentType("text/xml");
      out = response.getOutputStream();
      for (FileItem item : items) {
        if (!item.isFormField()) {
          out.print("<resource");
View Full Code Here

        // Set factory constraints
        factory.setSizeThreshold(FileUploadConfig.getBufferSize());
        factory.setRepository(new File(FileUploadConfig.getFileTempDir()));
       
        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);

        // Set overall request size constraint
        upload.setSizeMax(FileUploadConfig.getMaxFileSize());

        List<FileItem> fileItems = null;
        try {
            fileItems = upload.parseRequest(request);
        } catch (FileUploadException fue) {
            LOGGER.severe("File Upload Error", fue); //$NON-NLS-1$
            throw new Frame2Exception("File Upload Exception", fue); //$NON-NLS-1$
        }
View Full Code Here

    // TODO: This method is not used and should be removed. amb
    public static String uploadAndStoreImage(HttpServletRequest request, String idField, String uploadField) {
        //Delegator delegator = (Delegator) request.getAttribute("delegator");

        //String idFieldValue = null;
        ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp")));
        List<FileItem> lst = null;
        Locale locale = UtilHttp.getLocale(request);

        try {
            lst = UtilGenerics.checkList(fu.parseRequest(request));
        } catch (FileUploadException e) {
            request.setAttribute("_ERROR_MESSAGE_", e.toString());
            return "error";
        }
View Full Code Here


    private void parseMultiPartPost(ParameterMap parameters) {

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload();
        upload.setSizeMax(ParameterSupport.maxRequestSize);
        upload.setFileSizeMax(ParameterSupport.maxFileSize);
        upload.setFileItemFactory(new DiskFileItemFactory(ParameterSupport.fileSizeThreshold,
            ParameterSupport.location));

        RequestContext rc = new ServletRequestContext(this.getServletRequest()) {
            @Override
            public String getCharacterEncoding() {
                String enc = super.getCharacterEncoding();
                return (enc != null) ? enc : Util.ENCODING_DIRECT;
            }
        };

        // Parse the request
        List<?> /* FileItem */items = null;
        try {
            items = upload.parseRequest(rc);
        } catch (FileUploadException fue) {
            this.log.error("parseMultiPartPost: Error parsing request", fue);
        }

        if (items != null && items.size() > 0) {
View Full Code Here

        try {
            DiskFileItemFactory factory = new DiskFileItemFactory();
            // try to hold even largish bundles in memory to potentially improve performance
            factory.setSizeThreshold(UPLOAD_IN_MEMORY_SIZE_THRESHOLD);

            ServletFileUpload upload = new ServletFileUpload();
            upload.setFileItemFactory(factory);

            @SuppressWarnings("unchecked")
            List<FileItem> items = upload.parseRequest(req);
            if (items.size() != 1) {
                logAndWriteError("Found " + items.size() + " items to process, but only updating 1 bundle is supported", resp);
                return;
            }
View Full Code Here

        // Create a factory for disk-based file items
        DiskFileItemFactory factory = new DiskFileItemFactory();
        factory.setSizeThreshold(256000);

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        upload.setSizeMax(-1);

        // Parse the request
        boolean noRedirect = false;
        String bundleLocation = null;
        InputStream bundleStream = null;
        try {
            List /* FileItem */items = upload.parseRequest(req);

            Iterator iter = items.iterator();
            while (iter.hasNext()) {
                FileItem item = (FileItem) iter.next();

View Full Code Here

            {
                factory.setRepository( (File) repo );
            }

            // Create a new file upload handler
            ServletFileUpload upload = new ServletFileUpload( factory );
            upload.setSizeMax( -1 );

            // Parse the request
            params = new HashMap();
            try
            {
                List items = upload.parseRequest( request );
                for ( Iterator fiter = items.iterator(); fiter.hasNext(); )
                {
                    FileItem fi = ( FileItem ) fiter.next();
                    FileItem[] current = ( FileItem[] ) params.get( fi.getFieldName() );
                    if ( current == null )
View Full Code Here

        // Create a factory for disk-based file items
        FileItemFactory factory = new DiskFileItemFactory();

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);

        ArrayList<String> fileNames = new ArrayList<String>();
        try {
            // Parse the request
            List<FileItem> items = upload.parseRequest(request);
            Iterator<FileItem> iter = items.iterator();
            IVResource userDirectory = user.getResource(path);
            while (iter.hasNext()) {
                FileItem item = iter.next();
View Full Code Here

        Permissions.ensureAdmin(request);

        if (ServletFileUpload.isMultipartContent(request)) {
            Translations translations = ControllerUtils.getTranslations(request);

            ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory(100, null));
            List<FileItem> items;
            try {
                items = upload.parseRequest(request);

                for (FileItem item : items) {
                    if ("uploadFile".equals(item.getFieldName())) {
                        try {
                            int count = importCsv(item);
View Full Code Here

TOP

Related Classes of org.apache.commons.fileupload.servlet.ServletFileUpload

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.