Example usage for com.vaadin.server FileResource setCacheTime

List of usage examples for com.vaadin.server FileResource setCacheTime

Introduction

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

Prototype

public void setCacheTime(long cacheTime) 

Source Link

Document

Sets the length of cache expiration time.

Usage

From source file:nz.co.senanque.workflowui.AttachmentsPopup.java

License:Apache License

private void makeStream(final Attachment attachment) {
    final FileResource stream = new FileResource(new File("")) {
        private static final long serialVersionUID = 1L;

        @Override//from  ww  w  .j  a v  a2s  . c o m
        public DownloadStream getStream() {
            ByteArrayInputStream in = new ByteArrayInputStream(attachment.getBody());
            DownloadStream ds = new DownloadStream(in, attachment.getMIMEType(), attachment.getFileName());
            // Need a file download POPUP
            ds.setParameter("Content-Disposition", "attachment; filename=" + attachment.getFileName());
            return ds;
        }
    };
    stream.setCacheTime(0);
    Page.getCurrent().open(stream, "_blank", true);
    //        panel.requestRepaint();
}