/** * Returns the {@link DownloadStream} instance. * Unlike the method of the superclass, this one doesn't create a new instance if it is already existing. */ @Override public DownloadStream getStream() { if (downloadStream == null) { downloadStream = super.getStream(); } return downloadStream; }
public StreamResource getResource() { StreamSource source = new MyPdfSource((String) name.getValue()); String filename = new Random().nextInt() + "pdf_printing_example.pdf"; StreamResource resource = new StreamResource(source, filename); resource.setMIMEType("application/pdf"); resource.setCacheTime(0); resource.getStream().setParameter("Content-Disposition", "attachment; filename=" + filename); return resource; }
/** * Set DownloadStream-Parameter "Content-Disposition" to atachment, * therefore the Stream is downloaded and is not parsed as for example * "normal" xml. */ @Override public DownloadStream getStream() { DownloadStream ds = super.getStream(); ds.setParameter("Content-Disposition", "attachment; filename=\"" + getFilename() + "\""); return ds; }
/** * Set DownloadStream-Parameter "Content-Disposition" to atachment, * therefore the Stream is downloaded and is not parsed as for example * "normal" xml. */ @Override public DownloadStream getStream() { DownloadStream ds = super.getStream(); ds.setParameter("Content-Disposition", "attachment; filename=\"" + getFilename() + "\""); return ds; }
/** * Set DownloadStream-Parameter "Content-Disposition" to atachment, * therefore the Stream is downloaded and is not parsed as for example * "normal" xml. */ @Override public DownloadStream getStream() { DownloadStream ds = super.getStream(); ds.setParameter("Content-Disposition", "attachment; filename=\"" + getFilename() + "\""); return ds; }
@Override public DownloadStream getStream() { final DownloadStream stream = super.getStream(); if (StringUtils.isNotBlank(getFilename())) { String encodedFilename = EncodeUtil.rfc5987Encode(getFilename()); stream.setParameter("Content-Disposition", String.format("attachment;filename=\"%s\"; filename*=utf-8''%s", encodedFilename, encodedFilename)); } return stream; }
resource.getStream().setParameter( "Content-Disposition", "attachment; filename="+filename);