Error 500 when trying to read a PDF

0

In the view it looks like this:

<p:media cache="false" value="#{documents.readPDF()}" width="640px" height="480px" player="pdf" />

No bean looks like this:

public StreamedContent readPDF() {
        FileModel pdfModel = getDocumentPDF();
        InputStream stream = new ByteArrayInputStream(pdfModel.getBytes());
        return new DefaultStreamedContent(stream, "application/pdf", pdfModel.getFileName());
    }

But I get an error 500 link

    
asked by anonymous 22.09.2018 / 03:16

1 answer

0

Friend, you posted a local URL that we can not open, if you can kindly present a print of the screen with the error. For gentilza also review the permissions of the file.

I do not understand Java very well, but I tried to structure the code differently, could I test it?

If I'm talking bullshit, I'm sorry.

public StreamedContent readPDF() {
        try {
        FileModel pdfModel = getDocumentPDF();
        InputStream stream;
        stream = new ByteArrayInputStream(pdfModel.getBytes());
        StreamedContent file = new DefaultStreamedContent(stream, stream, "application/pdf", pdfModel.getFileName());
        return file;
    } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
        }
    
22.09.2018 / 04:44