Package org.apache.commons.fileupload

Examples of org.apache.commons.fileupload.DefaultFileItem


                    List items = upload.parseRequest(this.request);
                    Iterator iter = items.iterator();
                   
                    while (iter.hasNext()) {
                        //FileItem item = (FileItem) iter.next();
                        DefaultFileItem item = (DefaultFileItem) iter.next();
                        if (item.isFormField()) {
                            requestMultipart.put(item.getFieldName(), item.getString());
                            this.request.setAttribute(item.getFieldName(),item.getString());
                        }
                        else { // aus upload
                            if (item.getName() != null && !item.getName().equals("")) {
                                 //requestMultipart.put(item.getFieldName(),item.getStoreLocation());
                                 requestMultipart.put(item.getFieldName(), item.getStoreLocation().getAbsolutePath());
                                this.request.setAttribute(item.getFieldName(),item.getStoreLocation().getAbsolutePath());
                                this.importOriginalFileName = item.getName();
                            }
                            else {
                                requestMultipart.put(item.getFieldName(), "");
                                this.request.setAttribute(item.getFieldName(),"");
                            }
                           
                        }

                    }
View Full Code Here


        String cancelKey = peer.getId() + ".CANCEL";
        JFileChooser chooser = (JFileChooser) peer.getComponent();
        if (!StringUtils.isNullOrEmpty(inputForm.get(okKey)))
        {
            String fileKey = peer.getId() + ".File.ITEM";
            DefaultFileItem item = (DefaultFileItem) inputForm.get(fileKey);
            try
            {
                File f = File.createTempFile("fdi", new File(item.getName()).getName(), new File(System
                        .getProperty("java.io.tmpdir")));
                item.write(f);
                chooser.setSelectedFile(f);
                chooser.approveSelection();
            } catch (Exception e)
            {
                throw new InputException("Cannot save file", e);
View Full Code Here

        String cancelKey = peer.getId() + ".CANCEL";
        FileDialog dlg = (FileDialog) peer.getComponent();
        if (!StringUtils.isNullOrEmpty(inputForm.get(okKey)))
        {
            String fileKey = peer.getId() + ".File.ITEM";
            DefaultFileItem item = (DefaultFileItem) inputForm.get(fileKey);
            try
            {
                File f = File.createTempFile("fdi", new File(item.getName()).getName(),
                        new File(System.getProperty("java.io.tmpdir")));
                item.write(f);
                dlg.setFile(f.getName());
                dlg.setDirectory(f.getParent());
                dlg.hide(); //hide it like the peer implementation do
            } catch (Exception e)
            {               
View Full Code Here

        assertEquals(item.getSize(), testFieldValueBytes.length);
        assertTrue(Arrays.equals(item.get(), testFieldValueBytes));
        assertEquals(item.getString(), textFieldValue);

        assertTrue(item instanceof DefaultFileItem);
        DefaultFileItem dfi = (DefaultFileItem) item;
        File storeLocation = dfi.getStoreLocation();
        assertNotNull(storeLocation);
        assertTrue(storeLocation.exists());
        assertEquals(storeLocation.length(), testFieldValueBytes.length);

        if (repository != null)
View Full Code Here

        assertEquals(item.getSize(), testFieldValueBytes.length);
        assertTrue(Arrays.equals(item.get(), testFieldValueBytes));
        assertEquals(item.getString(), textFieldValue);

        assertTrue(item instanceof DefaultFileItem);
        DefaultFileItem dfi = (DefaultFileItem) item;
        File storeLocation = dfi.getStoreLocation();
        assertNotNull(storeLocation);
        assertTrue(storeLocation.exists());
        assertEquals(storeLocation.length(), testFieldValueBytes.length);

        if (repository != null)
View Full Code Here

        assertEquals(item.getSize(), testFieldValueBytes.length);
        assertTrue(Arrays.equals(item.get(), testFieldValueBytes));
        assertEquals(item.getString(), textFieldValue);

        assertTrue(item instanceof DefaultFileItem);
        DefaultFileItem dfi = (DefaultFileItem) item;
        File storeLocation = dfi.getStoreLocation();
        assertNotNull(storeLocation);
        assertTrue(storeLocation.exists());
        assertEquals(storeLocation.length(), testFieldValueBytes.length);

        if (repository != null)
View Full Code Here

TOP

Related Classes of org.apache.commons.fileupload.DefaultFileItem

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.