Example usage for com.vaadin.server StreamResource setBufferSize

List of usage examples for com.vaadin.server StreamResource setBufferSize

Introduction

In this page you can find the example usage for com.vaadin.server StreamResource setBufferSize.

Prototype

public void setBufferSize(int bufferSize) 

Source Link

Document

Sets the size of the download buffer used for this resource.

Usage

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);
}