Hey everyone,
Is there anyway to access the raw/original file stream from a client's machine via PrimeFaces (4.0.x, JSF 2.1)? Currently it appears that PrimeFaces uses a FileUploadFilter that leverages apache-commons fileupload and writes the item to disk first (assume a file size of 10MB) in a temporary location. This is an unnecessary step however as most applications will then write the file to another/final location, at which point the file has been written to disk twice.
Is there anyway to avoid this behavior and prevent the file being written to a temporary location and instead pass along the raw/original input stream to the JSF managed bean?
Thanks!
FileUpload - Access to Raw Stream
- andyba
- Expert Member
- Posts: 2473
- Joined: 31 Mar 2011, 16:27
- Location: Steinfeld, near Bremen/Osnabrück, DE
- Contact:
The reason that an upload is written to a tmp file if its length exceeds a specified value is to prevent overly large files causing your heap space to run out.
If you don't want this feature read the User Guide about how to set the file length after which files are written to tmp. I don't advise this though, because you will end up with unpredictable and fatal heap space problems.
If you don't want this feature read the User Guide about how to set the file length after which files are written to tmp. I don't advise this though, because you will end up with unpredictable and fatal heap space problems.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now
-
- Posts: 2
- Joined: 22 Sep 2014, 20:56
I'm not looking to store the file in memory (for the reasons you listed, e.g. 100MB file) -- I'm trying to access to the original stream of bytes coming from the client so I can write them to disk once, and only once. Right now the FileUploadFilter will either store the file in memory, or write it to a temporary location.andyba wrote:The reason that an upload is written to a tmp file if its length exceeds a specified value is to prevent overly large files causing your heap space to run out.
If you don't want this feature read the User Guide about how to set the file length after which files are written to tmp. I don't advise this though, because you will end up with unpredictable and fatal heap space problems.
I'm looking for a 3rd option, like this: http://commons.apache.org/proper/common ... aming.html, that is compatible with PF and the fileUpload tag.
I think this is not compatible with the jsf lifecycles. Just use the temp file, copy that efficiently (not using the getContents()) and remove the temp file. Very efficiently and will perforn good unless you have many users and little hd space (but you then have a different problem imo)
Hi dennisPrime.
Did you manage to get the Apache Commons FileUpload streaming API working with PF (or even bare JSF) ?
Did you manage to get the Apache Commons FileUpload streaming API working with PF (or even bare JSF) ?
Software Developer at Le Sénat - http://www.senat.fr/lng/en/index.html
When using PrimeFaces :
When using PrimeFaces :
- PrimeFaces Elite 5.2.5
- MyFaces 2.2.8
- OpenWebBeans 1.5.0
- Deltaspike 1.3.0
- Tomcat 8.0.23
-
- Information
-
Who is online
Users browsing this forum: No registered users and 35 guests