Title: How to store Files with InputFileUpload Permanently on disk?

I have a UploadForm where I can upload all type of Files to a filesystem...
The problem now is, that my files are only stored temporary. How can I tell Myfaces to store the files permanently on my disk?

Do I have to use a InputStream? Perhaps somebody has an example how to do that`?

Here is my code snippet and my web.xml..

JSF:
<td><t:inputFileUpload id="file" value="#{detailsDto.myFile}" storage="file">
</t:inputFileUpload><h:commandButton value="Load up" action="#{detailsDto.upload}"/></td>


BEAN:
public String upload()
    throws IOException
{
    FacesContext facesContext = FacesContext.getCurrentInstance();
    facesContext.getExternalContext().getApplicationMap().put("fileupload_bytes", myFile.getBytes());
    facesContext.getExternalContext().getApplicationMap().put("fileupload_type", myFile.getContentType());
    facesContext.getExternalContext().getApplicationMap().put("fileupload_name", myFile.getName());
    System.out.println("myFilename" +myFile.getName());
    return "ok";
}


WEB.XML
        <filter>
                <filter-name>extensionsFilter</filter-name>
                <filter-class>
                        org.apache.myfaces.component.html.util.ExtensionsFilter
                </filter-class>
                <init-param>
                        <param-name>uploadMaxFileSize</param-name>
                        <param-value>100m</param-value>
                </init-param>
                <init-param>
                        <param-name>uploadThresholdSize</param-name>
                        <param-value>10k</param-value>
                </init-param>
                 <init-param>
                        <param-name>uploadRepositoryPath</param-name>
                        <param-value>/temp</param-value>
                </init-param>
        </filter>

THX for help
Regards,
Andy


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify your system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to