use of com.vaadin.flow.component.upload.receivers.MultiFileBuffer in project flow-components by vaadin.
the class MultiFileBufferTest method shouldBeAbleToReadFilesAfterReceiving.
@Test
public void shouldBeAbleToReadFilesAfterReceiving() throws IOException {
MultiFileBuffer fileBuffer = new MultiFileBuffer();
TestData[] testData = { new TestData("upload1", "Upload data 1"), new TestData("upload2", "Upload data 2"), new TestData("upload3", "Upload data 3") };
for (TestData data : testData) {
final byte[] dataBytes = data.data.getBytes(Charset.defaultCharset());
try (OutputStream os = fileBuffer.receiveUpload(data.filename, "text")) {
os.write(dataBytes);
}
}
for (TestData data : testData) {
final String readData = IOUtils.toString(fileBuffer.getInputStream(data.filename), Charset.defaultCharset());
Assert.assertEquals(data.data, readData);
}
}
use of com.vaadin.flow.component.upload.receivers.MultiFileBuffer in project flow-components by vaadin.
the class FileBufferView method createMultiFileUpload.
private static Div createMultiFileUpload() {
final MultiFileBuffer buffer = new MultiFileBuffer();
final Upload multiFileUpload = new Upload(buffer);
multiFileUpload.setId("multi-upload");
return setupUploadSection(multiFileUpload, e -> buffer.getInputStream(e.getFileName()));
}
Aggregations