List of usage examples for com.vaadin.server StreamResource setBufferSize
public void setBufferSize(int bufferSize)
From source file:com.haulmont.cuba.web.gui.components.WebClasspathResource.java
License:Apache License
@Override protected void createResource() { String name = StringUtils.isNotEmpty(fileName) ? fileName : FilenameUtils.getName(path); resource = new StreamResource(() -> AppBeans.get(Resources.class).getResourceAsStream(path), name); StreamResource streamResource = (StreamResource) this.resource; streamResource.setMIMEType(mimeType); streamResource.setCacheTime(cacheTime); streamResource.setBufferSize(bufferSize); }
From source file:com.haulmont.cuba.web.gui.components.WebFileDescriptorResource.java
License:Apache License
@Override protected void createResource() { String name = StringUtils.isNotEmpty(fileName) ? fileName : fileDescriptor.getName(); resource = new StreamResource(() -> { try {/*ww w. j av a2 s.c o m*/ return new ByteArrayDataProvider(AppBeans.get(FileStorageService.class).loadFile(fileDescriptor)) .provide(); } catch (FileStorageException e) { throw new RuntimeException(FILE_STORAGE_EXCEPTION_MESSAGE, e); } }, name); StreamResource streamResource = (StreamResource) this.resource; streamResource.setCacheTime(cacheTime); streamResource.setBufferSize(bufferSize); }