Java Code Examples for org.apache.wicket.markup.html.form.upload.FileUpload

The following examples show how to use org.apache.wicket.markup.html.form.upload.FileUpload. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: openmeetings   Source File: UploadableImagePanel.java    License: Apache License 2.0 6 votes vote down vote up
public void process(Optional<AjaxRequestTarget> target) {
	FileUpload fu = fileUploadField.getFileUpload();
	if (fu != null) {
		File temp = null;
		try {
			temp = fu.writeToTempFile();
			StoredFile sf = new StoredFile(fu.getClientFileName(), temp);
			if (sf.isImage()) {
				processImage(sf, temp);
			}
		} catch (Exception e) {
			log.error("Error", e);
		} finally {
			if (temp != null && temp.exists()) {
				log.debug("Temp file was deleted ? {}", temp.delete());
			}
			fu.closeStreams();
			fu.delete();
		}
	}
	update(target);
}
 
Example 2
Source Project: ontopia   Source File: UploadIFrame.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onSubmit() {
  FileUpload upload = uploadField.getFileUpload();         
  if (upload != null) {
    try {
      Reader input = new InputStreamReader(new Base64InputStream(upload.getInputStream(), true), "utf-8");
      FieldInstance fieldInstance = fieldValueModel.getFieldInstanceModel().getFieldInstance();
      StringWriter swriter = new StringWriter();
      IOUtils.copy(input, swriter);
      String value = swriter.toString();
      fieldInstance.addValue(value, getLifeCycleListener());
      fieldValueModel.setExistingValue(value);
      uploaded = true;
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
 
Example 3
Source Project: Orienteer   Source File: BinaryEditPanel.java    License: Apache License 2.0 6 votes vote down vote up
public BinaryEditPanel(String id, IModel<byte[]> model) {
	super(id, model);
	fileUploadField = new FileUploadField("data", Model.ofList(new ArrayList<FileUpload>()));
	add(fileUploadField);
	fileUploadField.setOutputMarkupId(true);

	clear = new AjaxCheckBox("clear", Model.of(Boolean.FALSE)) {
		@Override
		protected void onUpdate(AjaxRequestTarget target) {
			Boolean shouldClear = clear.getConvertedInput();
			if (shouldClear) {
				fileUploadField.clearInput();
			}

			fileUploadField.setEnabled(!shouldClear);
			target.add(fileUploadField);
		}
	};

	add(clear);
}
 
Example 4
Source Project: Orienteer   Source File: BinaryEditPanel.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void convertInput() {
	if (clear.getConvertedInput())
	{
		setConvertedInput(null);
		tempName = null;
		return;
	}

	FileUpload fileUpload = fileUploadField.getFileUpload();
	if(fileUpload!=null) {
		setConvertedInput(fileUpload.getBytes());
		tempName = fileUpload.getClientFileName();
	}
	else {
		setConvertedInput(getModelObject());
	}
}
 
Example 5
Source Project: Orienteer   Source File: AbstractUploadFilePanel.java    License: Apache License 2.0 6 votes vote down vote up
public AbstractUploadFilePanel(String id, final ModalWindow modal,final AbstractModalWindowCommand<?> command) {
	super(id);
	modal.setMinimalHeight(300);
	modal.showUnloadConfirmation(false);
	Form<?> uploadForm = new Form<Object>("uploadForm");
	final FileUploadField inputFile = new FileUploadField("inputFile");
	uploadForm.add(inputFile);
	uploadForm.add(new AjaxButton("loadFile",getLoadButtonTitle(),uploadForm)
	{
		private static final long serialVersionUID = 1L;

		@Override
		protected void onSubmit(AjaxRequestTarget target) {
			FileUpload file = inputFile.getFileUpload();
			if (file!=null){
				onLoadFile(file);
				command.onAfterModalSubmit();
				modal.close(target);
			}
		}
		
	});
	add(uploadForm);		
}
 
Example 6
protected void importAccountList()
{
  checkAccess();
  final FileUpload fileUpload = form.fileUploadField.getFileUpload();
  if (fileUpload != null) {
    try {
      final InputStream is = fileUpload.getInputStream();
      actionLog.reset();
      final String clientFileName = fileUpload.getClientFileName();
      setStorage(datevImportDao.importKontenplan(is, clientFileName, actionLog));
    } catch (final Exception ex) {
      log.error(ex.getMessage(), ex);
      error("An error occurred (see log files for details): " + ex.getMessage());
      clear();
    }
  }
}
 
Example 7
protected void importAccountRecords()
{
  checkAccess();
  final FileUpload fileUpload = form.fileUploadField.getFileUpload();
  if (fileUpload != null) {
    try {
      final InputStream is = fileUpload.getInputStream();
      actionLog.reset();
      final String clientFileName = fileUpload.getClientFileName();
      setStorage(datevImportDao.importBuchungsdaten(is, clientFileName, actionLog));
    } catch (final Exception ex) {
      log.error(ex.getMessage(), ex);
      error("An error occurred (see log files for details): " + ex.getMessage());
      clear();
    }
  }
}
 
Example 8
protected void importReportObjectivs()
{
  checkAccess();
  log.info("import report objectives.");
  final FileUpload fileUpload = form.fileUploadField.getFileUpload();
  if (fileUpload != null) {
    try {
      final String clientFileName = fileUpload.getClientFileName();
      final InputStream is = fileUpload.getInputStream();
      final Report report = reportDao.createReport(is);
      reportStorage = new ReportStorage(report);
      reportStorage.setFileName(clientFileName);
      putUserPrefEntry(KEY_REPORT_STORAGE, reportStorage, false);
    } catch (final Exception ex) {
      log.error(ex.getMessage(), ex);
      error("An error occurred (see log files for details): " + ex.getMessage());
    }
  }
}
 
Example 9
protected void importEvents()
{
  checkAccess();
  final FileUpload fileUpload = form.fileUploadField.getFileUpload();
  if (fileUpload != null) {
    try {
      final InputStream is = fileUpload.getInputStream();
      actionLog.reset();
      final String clientFilename = fileUpload.getClientFileName();
      final CalendarBuilder builder = new CalendarBuilder();
      final Calendar calendar = builder.build(is);
      final ImportStorage<TeamEventDO> storage = teamCalImportDao.importEvents(calendar, clientFilename, actionLog);
      setStorage(storage);
    } catch (final Exception ex) {
      log.error(ex.getMessage(), ex);
      error("An error occurred (see log files for details): " + ex.getMessage());
      clear();
    } finally {
      fileUpload.closeStreams();
    }
  }
}
 
Example 10
Source Project: nextreports-server   Source File: LicenseErrorPage.java    License: Apache License 2.0 6 votes vote down vote up
@Override
      protected void onSubmit() {
          FileUpload upload = fileUploadField.getFileUpload();
          if (upload != null) {
              File licenseFile = new File(getUploadFolder(), "license.dat"/*upload.getClientFileName()*/);

              // check new file, delete if it allready existed
              checkFileExists(licenseFile);
              try {
                  // Save to new file
                  licenseFile.createNewFile();
                  upload.writeTo(licenseFile);

                  LicenseErrorPage.this.info("Uploaded file: " + upload.getClientFileName());
                  setResponsePage(getApplication().getHomePage());
              } catch (Exception e) {
                  throw new IllegalStateException("Unable to write file");
              }
          }
}
 
Example 11
Source Project: inception   Source File: FileUploadDownloadHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Writes the input stream to a temporary file. The file is deleted if the object behind marker
 * is garbage collected. The temporary file will keep its extension based on the specified file
 * name.
 *
 * @param fileUpload The file upload handle to write to the temporary file
 * @param marker The object to whose lifetime the temporary file is bound
 * @return A handle to the created temporary file
 */
public File writeFileUploadToTemporaryFile(FileUpload fileUpload, Object marker)
    throws IOException
{
    String fileName = fileUpload.getClientFileName();
    File tmpFile = File.createTempFile(INCEPTION_TMP_FILE_PREFIX, fileName);
    log.debug("Creating temporary file for [{}] in [{}]", fileName, tmpFile.getAbsolutePath());
    fileTracker.track(tmpFile, marker);
    try (InputStream is = fileUpload.getInputStream()) {
        FileUtils.copyInputStreamToFile(is, tmpFile);
    }
    return tmpFile;
}
 
Example 12
Source Project: inception   Source File: AccessSpecificSettingsPanel.java    License: Apache License 2.0 5 votes vote down vote up
public void handleUploadedFiles()
{
    try {
        for (FileUpload fu : fileUpload.getFileUploads()) {
            File tmp = uploadFile(fu);
            kbModel.getObject().putFile(fu.getClientFileName(), tmp);
        }
    }
    catch (Exception e) {
        log.error("Error while uploading files", e);
        error("Could not upload files");
    }
}
 
Example 13
Source Project: inception   Source File: AccessSpecificSettingsPanel.java    License: Apache License 2.0 5 votes vote down vote up
private File uploadFile(FileUpload fu) throws IOException
{
    String fileName = fu.getClientFileName();
    if (!uploadedFiles.containsKey(fileName)) {
        FileUploadDownloadHelper fileUploadDownloadHelper = new FileUploadDownloadHelper(
            getApplication());
        File tmpFile = fileUploadDownloadHelper.writeFileUploadToTemporaryFile(fu, kbModel);
        uploadedFiles.put(fileName, tmpFile);
    }
    else {
        log.debug("File [{}] already downloaded, skipping!", fileName);
    }
    return uploadedFiles.get(fileName);
}
 
Example 14
private void actionUploadGazeteer(AjaxRequestTarget aTarget)
{
    aTarget.addChildren(getPage(), IFeedback.class);
    aTarget.add(gazeteers);
    
    for (FileUpload importedGazeteer : uploadField.getModelObject()) {
        Gazeteer gazeteer = new Gazeteer();
        gazeteer.setName(importedGazeteer.getClientFileName());
        gazeteer.setRecommender(getModelObject());
        
        // Make sure the gazetter name is unique
        int n = 2;
        while (gazeteerService.existsGazeteer(gazeteer.getRecommender(), gazeteer.getName())) {
            String baseName = FilenameUtils.getBaseName(importedGazeteer.getClientFileName());
            String extension = FilenameUtils.getExtension(importedGazeteer.getClientFileName());
            gazeteer.setName(baseName + ' ' + n + '.' + extension);
            n++;
        }
        
        try (InputStream is = importedGazeteer.getInputStream()) {
            gazeteerService.createOrUpdateGazeteer(gazeteer);
            gazeteerService.importGazeteerFile(gazeteer, is);
            success("Imported gazeteer: [" + gazeteer.getName() + "]");
        }
        catch (Exception e) {
            error("Error importing gazeteer: " + ExceptionUtils.getRootCauseMessage(e));
            LOG.error("Error importing gazeteer", e);
        }
    }
}
 
Example 15
Source Project: onedev   Source File: DropzoneField.java    License: MIT License 5 votes vote down vote up
@Override
public void convertInput() {
	if (fileItems.isEmpty()) {
		setConvertedInput(null);
	} else {
		Collection<FileUpload> uploads = new ArrayList<>();
		for (FileItem fileItem: fileItems) {
			uploads.add(new FileUpload(fileItem));
		}
		setConvertedInput(uploads);
	}
}
 
Example 16
Source Project: webanno   Source File: ProjectLayersPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void actionImport(AjaxRequestTarget aTarget, Form<String> aForm)
{
    List<FileUpload> uploadedFiles = fileUpload.getFileUploads();
    Project project = ProjectLayersPanel.this.getModelObject();

    if (isEmpty(uploadedFiles)) {
        error("Please choose file with layer details before uploading");
        return;
    }
    else if (isNull(project.getId())) {
        error("Project not yet created, please save project details!");
        return;
    }
    for (FileUpload uploadedFile : uploadedFiles) {
        try (BufferedInputStream bis = IOUtils.buffer(uploadedFile.getInputStream())) {
            byte[] buf = new byte[5];
            bis.mark(buf.length + 1);
            bis.read(buf, 0, buf.length);
            bis.reset();

            // If the file starts with an XML preamble, then we assume it is an UIMA
            // type system file.
            if (Arrays.equals(buf, new byte[] { '<', '?', 'x', 'm', 'l' })) {
                importUimaTypeSystemFile(bis);
            }
            else {
                importLayerFile(bis);
            }
        }
        catch (Exception e) {
            error("Error importing layers: " + ExceptionUtils.getRootCauseMessage(e));
            aTarget.addChildren(getPage(), IFeedback.class);
            LOG.error("Error importing layers", e);
        }
    }
    featureDetailForm.setVisible(false);
    aTarget.add(ProjectLayersPanel.this);
}
 
Example 17
Source Project: webanno   Source File: ImportGuidelinesPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void actionImport(AjaxRequestTarget aTarget, Form<Void> aForm)
{
    List<FileUpload> uploadedFiles = fileUpload.getFileUploads();
    Project project = projectModel.getObject();

    if (isNull(project.getId())) {
        aTarget.addChildren(getPage(), IFeedback.class);
        error("Project not yet created, please save project details!");
        return;
    }
    if (isEmpty(uploadedFiles)) {
        aTarget.addChildren(getPage(), IFeedback.class);
        error("No document is selected to upload, please select a document first");
        return;
    }

    for (FileUpload guidelineFile : uploadedFiles) {
        try {
            // Workaround for WICKET-6425
            File tempFile = File.createTempFile("webanno-guidelines", null);
            try (InputStream is = guidelineFile.getInputStream();
                    OutputStream os = new FileOutputStream(tempFile);) {
                IOUtils.copyLarge(is, os);

                String fileName = guidelineFile.getClientFileName();
                projectRepository.createGuideline(project, tempFile, fileName);
            }
            finally {
                tempFile.delete();
            }
        }
        catch (Exception e) {
            error("Unable to write guideline file " + ExceptionUtils.getRootCauseMessage(e));
        }
    }

    WicketUtil.refreshPage(aTarget, getPage());
}
 
Example 18
Source Project: syncope   Source File: CSVPullWizardBuilder.java    License: Apache License 2.0 5 votes vote down vote up
public Details(final CSVPullSpec spec) {
    FileInputConfig csvFile = new FileInputConfig().
            showUpload(false).showRemove(false).showPreview(false).
            browseClass("btn btn-success").browseIcon("<i class=\"fas fa-folder-open\"></i> &nbsp;");
    String language = SyncopeConsoleSession.get().getLocale().getLanguage();
    if (!Locale.ENGLISH.getLanguage().equals(language)) {
        csvFile.withLocale(language);
    }
    BootstrapFileInputField csvUpload =
            new BootstrapFileInputField("csvUpload", new ListModel<>(new ArrayList<>()), csvFile);
    csvUpload.add(new AjaxFormSubmitBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = 5538299138211283825L;

        @Override
        protected void onSubmit(final AjaxRequestTarget target) {
            FileUpload uploadedFile = csvUpload.getFileUpload();
            if (uploadedFile != null) {
                if (maxUploadSize != null && uploadedFile.getSize() > maxUploadSize.bytes()) {
                    SyncopeConsoleSession.get().error(getString("tooLargeFile").
                            replace("${maxUploadSizeB}", String.valueOf(maxUploadSize.bytes())).
                            replace("${maxUploadSizeMB}", String.valueOf(maxUploadSize.bytes() / 1000000L)));
                    ((BasePage) getPageReference().getPage()).getNotificationPanel().refresh(target);
                } else {
                    csv.setObject(uploadedFile.getBytes());
                }
            }
        }
    });
    add(csvUpload.setRequired(true).setOutputMarkupId(true));

    add(new CSVConfPanel("csvconf", spec));
}
 
Example 19
Source Project: Orienteer   Source File: OrienteerClassLoaderUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Add artifact jar file to temp folder
 * @param artifactName artifact name
 * @param fileUpload {@link FileUpload} of artifact's jar
 * @return {@link File} of artifact's jar file or Optional.absent() if can't add artifact's jar file to folder
 * @throws IllegalArgumentException if artifactName is null or empty. Or when fileUpload is null.
 */
public static File createJarTempFile(String artifactName, FileUpload fileUpload) {
    Args.notEmpty(artifactName, "artifactName");
    Args.notNull(fileUpload, "fileUpload");
    String fileName = fileUpload.getClientFileName();
    try {
        File file = File.createTempFile(fileName.replaceAll("\\.jar", ""), ".jar");
        fileUpload.writeTo(file);
        return file;
    } catch (Exception e) {
        LOG.error("Cannot upload file: {}", fileName, e);
    }
    return null;
}
 
Example 20
Source Project: Orienteer   Source File: ImageEditPanel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void validate() {
    super.validate();
    FileUpload fileUpload = fileUploadField.getFileUpload();
    if(fileUpload!=null) {
        byte[] bytes = fileUpload.getBytes();
        boolean isImage = new Tika().detect(bytes).startsWith("image/");
        if (!isImage) {
            error(getString("errors.wrong.image.uploaded"));
        }
    }
}
 
Example 21
Source Project: Orienteer   Source File: UserOArtifactPanel.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private File getJarFile(FileUploadField fileUploadField) {
    FileUpload fileUpload = fileUploadField.getFileUpload();
    if (fileUpload == null) return null;
    String clientFileName = fileUpload.getClientFileName();
    if (!fileUpload.getClientFileName().endsWith(".jar")) return null;
    return OrienteerClassLoaderUtil.createJarTempFile(clientFileName, fileUpload);
}
 
Example 22
protected void upload()
{
  accessChecker.checkIsLoggedInUserMemberOfGroup(ProjectForgeGroup.FINANCE_GROUP, ProjectForgeGroup.CONTROLLING_GROUP);
  accessChecker.checkRestrictedOrDemoUser();
  log.info("upload");
  final FileUpload fileUpload = form.fileUploadField.getFileUpload();
  if (fileUpload != null) {
    final boolean delete = false;
    try {
      final InputStream is = fileUpload.getInputStream();
      final String clientFileName = fileUpload.getClientFileName();
      if (clientFileName.endsWith(".jrxml") == true) {
        log.error("Jasper reports not supported.");
        // delete = true;
        // final JasperReport report = JasperCompileManager.compileReport(is);
        // if (report != null) {
        // getReportScriptingStorage().setJasperReport(report, clientFileName);
        // }
      } else if (clientFileName.endsWith(".xls") == true) {
        final StringBuffer buf = new StringBuffer();
        buf.append("report_").append(FileHelper.createSafeFilename(PFUserContext.getUser().getUsername(), 20)).append(".xls");
        final File file = new File(ConfigXml.getInstance().getWorkingDirectory(), buf.toString());
        fileUpload.writeTo(file);
        getReportScriptingStorage().setFilename(clientFileName, file.getAbsolutePath());
      } else {
        log.error("File extension not supported: " + clientFileName);
      }
    } catch (final Exception ex) {
      log.error(ex.getMessage(), ex);
      error("An error occurred (see log files for details): " + ex.getMessage());
    } finally {
      if (delete == true) {
        fileUpload.delete();
      }
    }
  }
}
 
Example 23
/**
 * @see org.apache.wicket.Component#onInitialize()
 */
@Override
protected void onInitialize()
{
  super.onInitialize();
  gridBuilder.newSplitPanel(GridSize.COL50);
  final FieldsetPanel newFieldset = gridBuilder.newFieldset(getString("address.book.vCardImport.fileUploadPanel"));

  final FileUploadField uploadField = new FileUploadField(FileUploadPanel.WICKET_ID, new PropertyModel<List<FileUpload>>(this, "uploads"));
  newFieldset.add(new FileUploadPanel(newFieldset.newChildId(), uploadField));
}
 
Example 24
/**
 * Called by validator.
 */
protected void upload(final FileUpload fileUpload)
{
  if (fileUpload != null) {
    final String clientFileName = FileHelper.createSafeFilename(fileUpload.getClientFileName(), 255);
    log.info("Upload file '" + clientFileName + "'.");
    final byte[] bytes = fileUpload.getBytes();
    filename.setObject(clientFileName);
    file.setObject(bytes);
  }
}
 
Example 25
Source Project: inception   Source File: ProjectsOverviewPage.java    License: Apache License 2.0 4 votes vote down vote up
private void actionImport(AjaxRequestTarget aTarget, Form<Void> aForm)
{
    aTarget.addChildren(getPage(), IFeedback.class);
    
    List<FileUpload> exportedProjects = fileUpload.getFileUploads();
    for (FileUpload exportedProject : exportedProjects) {
        try {
            // Workaround for WICKET-6425
            File tempFile = File.createTempFile("project-import", null);
            try (
                    InputStream is = new BufferedInputStream(exportedProject.getInputStream());
                    OutputStream os = new FileOutputStream(tempFile);
            ) {
                if (!ZipUtils.isZipStream(is)) {
                    throw new IOException("Invalid ZIP file");
                }
                IOUtils.copyLarge(is, os);
                
                if (!ImportUtil.isZipValidWebanno(tempFile)) {
                    throw new IOException("ZIP file is not a valid project archive");
                }
                
                ProjectImportRequest request = new ProjectImportRequest(false, false,
                        Optional.of(userRepository.getCurrentUser()));
                Project importedProject = exportService.importProject(request,
                        new ZipFile(tempFile));
                
                success("Imported project: " + importedProject.getName());
            }
            finally {
                tempFile.delete();
            }
        }
        catch (Exception e) {
            error("Error importing project: " + ExceptionUtils.getRootCauseMessage(e));
            LOG.error("Error importing project", e);
        }
    }
    
    // After importing new projects, they should be visible in the overview, but we do not
    // redirect to the imported project. Could do that... maybe could do that if only a single
    // project was imported. Could also highlight the freshly imported projects somehow.
    
    aTarget.add(projectListContainer);
}
 
Example 26
Source Project: openmeetings   Source File: BackupPanel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setObject(List<FileUpload> object) {
	//no-op
}
 
Example 27
Source Project: openmeetings   Source File: BackupPanel.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public List<FileUpload> getObject() {
	return new ArrayList<>();
}
 
Example 28
Source Project: openmeetings   Source File: UploadDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void setObject(List<FileUpload> object) {
	//no-op
}
 
Example 29
Source Project: openmeetings   Source File: UploadDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public List<FileUpload> getObject() {
	return new ArrayList<>();
}
 
Example 30
Source Project: openmeetings   Source File: UploadDialog.java    License: Apache License 2.0 4 votes vote down vote up
private void convertAll() {
	List<FileUpload> ful = uploadField.getFileUploads();
	final BaseFileItem parent = roomFiles.getLastSelected();
	boolean clean = cleanWb.getModelObject();
	final long totalSize = ful.stream().mapToLong(FileUpload::getSize).sum();
	long currentSize = 0;
	for (FileUpload fu : ful) {
		long size = fu.getSize();
		try {
			FileItem f = new FileItem();
			f.setSize(size);
			f.setName(fu.getClientFileName());
			if (parent == null || !(parent instanceof FileItem)) {
				f.setOwnerId(getUserId());
			} else {
				f.setRoomId(parent.getRoomId());
				f.setOwnerId(parent.getOwnerId());
				f.setGroupId(parent.getGroupId());
				if (parent.getId() != null) {
					f.setParentId(BaseFileItem.Type.FOLDER == parent.getType() ? parent.getId() : parent.getParentId());
				}
			}
			f.setInsertedBy(getUserId());

			ProcessResultList logs = processor.processFile(f, fu.getInputStream()
					, Optional.<DoubleConsumer>of(part -> progress += (int)(100 * part * size / totalSize)));
			for (ProcessResult res : logs.getJobs()) {
				fileLogDao.add(res.getProcess(), f, res);
			}
			if (logs.hasError()) {
				form.error(getString("convert.errors.file"));
			} else {
				if (toWb.getModelObject()) {
					room.getWb().sendFileToWb(f, clean);
					clean = false;
				}
			}
		} catch (Exception e) {
			log.error("Unexpected error while processing uploaded file", e);
			form.error(e.getMessage() == null ? "Unexpected error" : e.getMessage());
		} finally {
			fu.closeStreams();
			fu.delete();
		}
		currentSize += size;
		progress = (int)(100 * currentSize / totalSize);
	}
	progress = 100;
}