I have the next problem. I try to upload 20 images at the same time.
1. The normal uploader
2. Select 20 images at the same time
3. The upload component shows all images and here is all fine
4. Make click on upload button for loading all images and in this part I put a debug point for breaking the upload and can validate what happen, so now I can see that the browser send 20 POST request. Here is all OK
5. Now, after processing the first POST request entry once at the method but process two POST lines, finally only load 12 images
6. Only load 12 images
So, it's the issue. I try in tomcat 7.57, Jetty 7, tomcat 8.018 using mojarra 2.011 and 2.28 but no, not work.
I let the code
xhtml
Code: Select all
<p:fileUpload style="width:100%" fileUploadListener="#{propertyBean.handleFileUpload}" auto="false" multiple="true" fileLimit="20" immediate="true" mode="advanced" previewWidth="60" dragDropSupport="true" sizeLimit="10000000" update="uploadedImage uploadedImageListError @this" process="@all" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" onstart="PF('statusDialog').show()" oncomplete="PF('statusDialog').hide();" />
Code: Select all
@Synchronized
public void handleFileUpload(FileUploadEvent event) {
try {
if (event != null) {
BufferedImage baseImage = ImageIO.read(event.getFile().getInputstream());
int w = baseImage.getWidth();
int h = baseImage.getHeight();
boolean error = false;
if (w < 200) {
error = true;
}
if (h < 200) {
error = true;
}
this.propertyFile = event.getFile();
this.fileName = null;
String fileTmpName = event.getFile().getFileName();
String extensionFile = fileTmpName.substring(fileTmpName.lastIndexOf("."), fileTmpName.length());
this.fileName = loadRandomName();
this.fileName += extensionFile;
if (!error) {
if (propertyFileList.size() > 0) {
counter = propertyFileList.size() + 1;
} else {
counter = 0;
counter++;
}
}
InputStream is = addWaterMarkTofile(event.getFile().getInputstream(), generalPath);
if (!error) {
propertyFileList.add(new PropertyFileUtil(fileName, event.getFile(), counter));
propertyFileListCpy.add(new PropertyFileUtil(fileName, event.getFile(), counter));
} else {
propertyFileListError.add(new PropertyFileUtil(fileName, event.getFile(), counter));
}
log.info("file move to " + generalPath + PROPERTY_TMP_PATH + fileName);
FileUploadManager.uploadFile(is, generalPath + PROPERTY_TMP_PATH, fileName);
}
} catch (Exception e) {
ErrorNotificacion.handleErrorMailNotification(e, this);
}
}
Code: Select all
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>commons</param-value>
</context-param>
<listener>
<listener-class>org.apache.commons.fileupload.servlet.FileCleanerCleanup</listener-class>
</listener>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<init-param>
<param-name>thresholdSize</param-name>
<param-value>25000</param-value>
</init-param>
<init-param>
<param-name>uploadDirectory</param-name>
<param-value>C:/opt/tucasa/temp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
PF: 5.1.19
Server: Tomcat 7.57
PFE: 3.0
Omnifaces: 1.8.1
Prettyfaces: 2.2.3
Mojarra: 2.28