Package org.directwebremoting.io

Examples of org.directwebremoting.io.FileTransfer


    }

    @Override
    @RemoteMethod
    public FileTransfer printGrid(String docType, GridDTO gridData) throws Exception {
        return new FileTransfer("grid." + ("PDF".equals(docType) ? "pdf" : "xls"), "application/" + docType.toLowerCase(), FileCopyUtils.copyToByteArray(reportEngine.generateGridReport(docType, gridData)));
    }
View Full Code Here


        File upload = new File("web/images/i18n/globe.gif");
        FileInputStream stream = new FileInputStream(upload);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        FileCopyUtils.copy(stream, out);
        ByteArrayInputStream bytes = new ByteArrayInputStream(out.toByteArray());
        transfer = new FileTransfer("globe.gif", "image/gif", bytes);
        factory = Persistence.createEntityManagerFactory("MODEL");
        entityManager = factory.createEntityManager();
        entityManager.getTransaction().begin();
    }
View Full Code Here

                }

                if (formField.isFile())
                {
                    InputStreamFactory inFactory = new SimpleInputStreamFactory(formField.getInputStream());
                    value = new FileTransfer(formField.getName(), formField.getMimeType(), formField.getFileSize(), inFactory);
                }
                else
                {
                    value = formField.getString();
                }
View Full Code Here

        {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
        }
        id = id.substring(downloadHandlerUrl.length());

        FileTransfer transfer = downloadManager.getFileTransfer(id);
        if (transfer == null)
        {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
        }
        else
        {
            if (transfer.getSize() > 0)
            {
                response.setContentLength((int) transfer.getSize());
            }

            String filename = transfer.getFilename();
            if (filename != null)
            {
                response.setHeader("Content-disposition", "attachment; filename=\"" + filename + "\"");
            }

            response.setContentType(transfer.getMimeType());

            OutputStreamLoader loader = null;
            try
            {
                loader = transfer.getOutputStreamLoader();
                loader.load(response.getOutputStream());
            }
            finally
            {
                LocalUtil.close(loader);
View Full Code Here

                    public void close() throws IOException
                    {
                        formField.getInputStream().close();
                    }
                };
                return new FileTransfer(formField.getName(), formField.getMimeType(), formField.getFileSize(), inFactory);
            }
            else if (paramType == InputStream.class)
            {
                return formField.getInputStream();
            }
View Full Code Here

            return new NonNestedOutboundVariable("null");
        }

        try
        {
            FileTransfer transfer;

            if (object instanceof BufferedImage)
            {
                transfer = new FileTransfer((BufferedImage) object, "png");
            }
            else if (object instanceof InputStream)
            {
                final InputStream in = (InputStream) object;
                transfer = new FileTransfer("download.dat", "binary/octet-stream", -1, new InputStreamFactory()
                {
                    public InputStream getInputStream() throws IOException
                    {
                        return in;
                    }

                    public void close() throws IOException
                    {
                        in.close();
                    }
                });
            }
            else if (object instanceof FileTransfer)
            {
                transfer = (FileTransfer) object;
            }
            else if (object.getClass().isArray() && object.getClass().getComponentType() == Byte.TYPE)
            {
                transfer = new FileTransfer("download.dat", "binary/octet-stream", (byte[]) object);
            }
            else
            {
                throw new ConversionException(object.getClass());
            }
View Full Code Here

        // Parts 0 and 1 are the prefix and id. We know they're right
        String mimeType = parts[2].replace(".", "/");
        String filename = parts[3];
        final InputStream in = new FileInputStream(matched);

        return new FileTransfer(filename, mimeType, matched.length(), new InputStreamFactory()
        {
            public InputStream getInputStream() throws IOException
            {
                return in;
            }
View Full Code Here

        // Parts 0 and 1 are the prefix and id. We know they're right
        String mimeType = decodeFileNameSegment(parts[2]);
        String filename = decodeFileNameSegment(parts[3]);
        final InputStream in = new FileInputStream(matched);

        return new FileTransfer(filename, mimeType, matched.length(), new InputStreamFactory()
        {
            public InputStream getInputStream() throws IOException
            {
                return in;
            }
View Full Code Here

        document.addCreator("DWR.war using iText");
        document.open();
        document.add(new Paragraph(contents));
        document.close();

        return new FileTransfer("example.pdf", "application/pdf", buffer.toByteArray());
    }
View Full Code Here

TOP

Related Classes of org.directwebremoting.io.FileTransfer

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.