use of com.vaadin.flow.component.upload.receivers.FileBuffer in project flow-components by vaadin.
the class FileBufferTest method shouldBeAbleToReadFileAfterReceiving.
@Test
public void shouldBeAbleToReadFileAfterReceiving() throws IOException {
FileBuffer fileBuffer = new FileBuffer();
final String data = "Upload data";
final byte[] dataBytes = data.getBytes(Charset.defaultCharset());
try (OutputStream os = fileBuffer.receiveUpload("uploadData", "text")) {
os.write(dataBytes);
}
final String readData = IOUtils.toString(fileBuffer.getInputStream(), Charset.defaultCharset());
Assert.assertEquals(data, readData);
}
use of com.vaadin.flow.component.upload.receivers.FileBuffer in project flow-components by vaadin.
the class FileBufferView method createSingleFileUpload.
private static Div createSingleFileUpload() {
final FileBuffer buffer = new FileBuffer();
final Upload singleFileUpload = new Upload(buffer);
singleFileUpload.setId("single-upload");
singleFileUpload.setMaxFiles(1);
return setupUploadSection(singleFileUpload, e -> buffer.getInputStream());
}
Aggregations