Dear,
uploading a big file (900MB) using rich:fileUpload give me java.lang.OutOfMemoryError: Java heap space. There is a way to solve the problem?
<rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
id="upload" acceptedTypes="txt,csv,pdf,iso,tar,zip,tgz,gz"
ontyperejected="alert('Only Text and CSV files are accepted');"
doneLabel="#{fileUploadBean.uploadDoneLabel}"
maxFilesQuantity="5">
<a4j:ajax event="uploadcomplete" execute="@none" render="info" />
</rich:fileUpload>
public void listener(FileUploadEvent event) throws Exception {
ufile = new UploadFile();
UploadedFile item = event.getUploadedFile();
UploadedText file = new UploadedText();
file.setLength(item.getData().length);
file.setName(item.getName());
Date date = new Date();
String epoch = fDir + String.valueOf(date.getTime());
File fPath = new File(epoch);
fPath.mkdir();
//file.setData(item.getData());
files.add(file);
String filename = epoch + '/' + item.getName();
FileOutputStream fop = null;
File fout;
if (file.getLength() > 0) {
try {
fout = new File(filename);
fop = new FileOutputStream(fout);
if (!fout.exists()) {
fout.createNewFile();
}
fop.write(item.getData());
fop.flush();
fop.close();
Thanks