本文整理汇总了Java中com.vaadin.server.DownloadStream类的典型用法代码示例。如果您正苦于以下问题:Java DownloadStream类的具体用法?Java DownloadStream怎么用?Java DownloadStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DownloadStream类属于com.vaadin.server包,在下文中一共展示了DownloadStream类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getStream
import com.vaadin.server.DownloadStream; //导入依赖的package包/类
/**
* Gets the stream.
*
* @return the stream
*/
/*
* (non-Javadoc)
*
* @see com.vaadin.terminal.StreamResource#getStream()
*/
@Override
public DownloadStream getStream() {
final DownloadStream stream = new DownloadStream(getStreamSource().getStream(), this.contentType,
this.filename);
stream.setParameter("Content-Disposition", "attachment;filename=" + this.filename);
// This magic incantation should prevent anyone from caching the data
stream.setParameter("Cache-Control", "private,no-cache,no-store");
// In theory <=0 disables caching. In practice Chrome, Safari (and,
// apparently, IE) all
// ignore <=0. Set to 1s
stream.setCacheTime(1000);
return stream;
}
开发者ID:bonprix,项目名称:vaadin-excel-exporter,代码行数:25,代码来源:TemporaryFileDownloadResource.java
示例2: createFileResource
import com.vaadin.server.DownloadStream; //导入依赖的package包/类
public FileResource createFileResource(File file)
{
return new FileResource(file)
{
private static final long serialVersionUID = -4183674760353232866L;
@Override
public DownloadStream getStream()
{
try
{
final DownloadStream ds = new DownloadStream(new FileInputStream(getSourceFile()), getMIMEType(), getFilename());
ds.setParameter("Content-Length", String.valueOf(getSourceFile().length()));
ds.setCacheTime(getCacheTime());
return ds;
}
catch (final FileNotFoundException e)
{
return null;
}//end try-catch block...
}//end method...
};
}
开发者ID:bonprix,项目名称:solidsearch-bot,代码行数:25,代码来源:FileResourceUtil.java
示例3: getStream
import com.vaadin.server.DownloadStream; //导入依赖的package包/类
@Override
public DownloadStream getStream() {
DownloadStream download = new DownloadStream(super.getStreamSource().getStream(),contentType,fileName);
download.setCacheTime(2000);
return download;
}
开发者ID:JumpMind,项目名称:sqlexplorer-vaadin,代码行数:7,代码来源:ExportFileDownloader.java
示例4: getStream
import com.vaadin.server.DownloadStream; //导入依赖的package包/类
@Override
public DownloadStream getStream()
{
final StreamSource ss = getStreamSource();
PartialDownloadStream ds = new PartialDownloadStream(null, getMIMEType(), getFilename());
if (ss != null)
{
try
{
long contentLength = contentLengthProvider.getContentLength();
ds.setStream(ss.getStream());
ds.setContentLength(contentLength);
ds.setParameter("Content-Length", String.valueOf(contentLength));
ds.setBufferSize(getBufferSize());
ds.setCacheTime(getCacheTime());
}
catch (final Exception e)
{
logger.error(e, e);
if (ui != null)
{
ui.access(new Runnable()
{
@Override
public void run()
{
Notification.show(e.getMessage(), Type.ERROR_MESSAGE);
}
});
}
else
{
ErrorWindow.showErrorWindow(e);
}
}
}
return ds;
}
开发者ID:rlsutton1,项目名称:VaadinUtils,代码行数:45,代码来源:StreamResourceWithContentLength.java
注:本文中的com.vaadin.server.DownloadStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论