@Override public DownloadStream getStream() { try { final DownloadStream ds = new DownloadStream( new FileInputStream(sourceFile), getMIMEType(), getFilename()); ds.setParameter("Content-Length", String.valueOf(sourceFile.length())); ds.setBufferSize(getBufferSize()); ds.setCacheTime(getCacheTime()); return ds; } catch (final FileNotFoundException e) { throw new RuntimeException( "File not found: " + sourceFile.getName(), e); } }
@Override public DownloadStream getStream() { final DownloadStream ds = new DownloadStream( getAssociatedClass().getResourceAsStream(resourceName), getMIMEType(), getFilename()); ds.setBufferSize(getBufferSize()); ds.setCacheTime(getCacheTime()); return ds; }
@Override public DownloadStream getStream() { final StreamSource ss = getStreamSource(); if (ss == null) { return null; } final DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename()); ds.setBufferSize(getBufferSize()); ds.setCacheTime(getCacheTime()); return ds; }
@Override 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; } };