Could anyone help me with the following issue: I have a Java web application using Vaadin as a framework(version 7.7.3) for the web interface. A user can upload a file in different formats such as PDF, TXT, DOCX, JPEG and I store this file as a byte array in our database. I need to implement a code that will allow a user to preview this file in the web interface if needed.
I have tried this code to achieve that for .pdf file.
StreamResource resource = new StreamResource(() -> new ByteArrayInputStream(pgwApplicationData.getMobileFileContent()), pgwApplicationData.getMobileFileName());
Embedded pdf = new Embedded(messageEmbedder.getMessage("preenrollment.file.context") + ":", resource);
pdf.setMimeType("application/pdf");
pdf.setType(Embedded.TYPE_BROWSER);
firstLayout.setSizeFull();
firstLayout.addComponent(pdf);
But it doesn't work for me for some reasons. When I try to preview a file in a separate window, the only thing I can see is this image
with the inscription that says "www.xxxxxx.com refused to connect"
I also noticed in the browser console that this code generated some URL(like ....web/APP/global/0/legacy/9/test_file.pdf) to my file. Please help me with that. Thank u in advance.