Example usage for com.vaadin.server DownloadStream DownloadStream

List of usage examples for com.vaadin.server DownloadStream DownloadStream

Introduction

In this page you can find the example usage for com.vaadin.server DownloadStream DownloadStream.

Prototype

public DownloadStream(InputStream stream, String contentType, String fileName) 

Source Link

Document

Creates a new instance of DownloadStream.

Usage

From source file:org.hip.vif.admin.admin.print.DownloadFile.java

License:Open Source License

@Override
public DownloadStream getStream() {
    try {/*www  . ja  va 2  s . c om*/
        final DownloadStream out = new DownloadStream(buffer.getInputStream(), getMIMEType(), getFileName());
        out.setCacheTime(0);
        out.setParameter("Content-Disposition", "attachment; filename=\"" + getFileName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        out.setParameter("Content-Length", String.valueOf(buffer.getSize() - buffer.getSpaceLeft())); //$NON-NLS-1$
        out.setContentType("application/octet-stream;charset=UTF-8");
        LOG.debug("Printed discusion group to file \"{}\".", getFileName()); //$NON-NLS-1$
        return out;
    } catch (final Exception exc) {
        LOG.error("Error encountered while printing the discussion groups!", exc); //$NON-NLS-1$
    }
    return null;
}

From source file:org.hip.vif.web.util.DownloadFileResouce.java

License:Open Source License

@Override
public DownloadStream getStream() {
    try {//from  ww  w  . j av  a2s.co m
        final DownloadStream out = new DownloadStream(new FileInputStream(download.getFile()),
                download.getMIMEType(), download.getFileName());
        out.setCacheTime(0);
        out.setParameter("Content-Disposition", "attachment; filename=\"" + download.getFileName() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        LOG.debug("Downloaded file \"{}\"", download.getFileName()); //$NON-NLS-1$
        return out;
    } catch (final FileNotFoundException exc) {
        LOG.error("Couldn't find download file \"{}\"!", download.getFileName(), exc); //$NON-NLS-1$
        return null;
    }
}

From source file:org.lucidj.vaadinui.BundleResource.java

License:Apache License

@Override
public DownloadStream getStream() {
    try {/*ww  w  . j a  v a  2  s . c o m*/
        DownloadStream ds = new DownloadStream(resourceUrl.openStream(), getMIMEType(), getFilename());
        ds.setBufferSize(getBufferSize());
        ds.setCacheTime(getCacheTime());
        return (ds);
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    }
}