Upload PrimeFaces Directory

2

I am uploading with PrimeFaces where the upload is in the Project Resources folder, however I want to use another directory to store the files, preferably in the root directory where Tomcat is located.

Any suggestions on how to get this path?

I'm currently using this way: FacesContext.getCurrentInstance().getExternalContext().getRealPath("/") + "resources/files/";

    
asked by anonymous 18.10.2016 / 15:31

2 answers

1

Edit the file web.xml and add or change the entry:

<init-param>
    <param-name>uploadDirectory</param-name>
    <param-value>/path/to/uploads</param-value>
</init-param>

Source: link

    
18.10.2016 / 15:36
0

I'm using this way: XHTML: <p:graphicImage value="#{emitenteBean.myImage}"

BEAN:

private StreamedContent myImage;

try {
FileInputStream fileInputStream = new FileInputStream("/Users/user/files/minhaImg.jpg");
myImage = new DefaultStreamedContent(fileInputStream, "image/jpeg");

    } catch (FileNotFoundException e) {
        System.out.println("ERRO AO CONVERTER IMG.");
    }
    
18.10.2016 / 19:34