the upload component can't work in latest vaddin 12.0.0
LaiZhou opened this issue · 1 comments
LaiZhou commented
when upgrade to 12.0.0,the upload component can't listen the event.
code:
MultiFileMemoryBuffer buffer = new MultiFileMemoryBuffer();
upload.setReceiver(buffer);
upload.setAcceptedFileTypes("image/jpeg", "image/png", "image/gif", "image/jpg");
upload.addSucceededListener(event -> {
try {
String imgName = MD5Util.md5(UUID.randomUUID().toString()) + "." + event.getFileName().split("\\.")[1];
FileUtils.writeByteArrayToFile(new File("/statics/imgs/" + imgName),
IOUtils.toByteArray(buffer.getInputStream(event.getFileName())));
getModel().getImgs().add(imgName);
} catch (Exception e) {
getLogger().error("upload error", e);
showNotification("图片保存失败:"+e.getMessage(),true);
}
});
limonte commented
This issue was moved to vaadin/vaadin-upload-flow#104