/** * {@inheritDoc} */ @Override public FileUpload create(final MultipartRequestInputStream input) { return new AdaptiveFileUpload(input, memoryThreshold, uploadPath, maxFileSize, breakOnError, fileExtensions, allowFileExtensions); }
/** * Determines if upload is allowed. */ protected boolean checkUpload() throws IOException { if (fileExtensions != null) { if (!matchFileExtension()) { return false; } } return true; }
/** * Writes file uploaded item. */ public File write(final String destination) throws IOException { return write(new File(destination)); }
protected boolean matchFileExtension() throws IOException { String fileNameExtension = FileNameUtil.getExtension(getHeader().getFileName()); for (String fileExtension : fileExtensions) { if (fileNameExtension.equalsIgnoreCase(fileExtension)) { if (!allowFileExtensions) { // extension matched and it is not allowed if (breakOnError) { throw new IOException("Upload filename extension not allowed: " + fileNameExtension); } size = input.skipToBoundary(); return false; } return true; // extension matched and it is allowed. } } if (allowFileExtensions) { // extension is not one of the allowed ones. if (breakOnError) { throw new IOException("Upload filename extension not allowed: " + fileNameExtension); } size = input.skipToBoundary(); return false; } return true; }
@Override protected void processStream() throws IOException { if (!checkUpload()) { return;
protected boolean matchFileExtension() throws IOException { String fileNameExtension = FileNameUtil.getExtension(getHeader().getFileName()); for (String fileExtension : fileExtensions) { if (fileNameExtension.equalsIgnoreCase(fileExtension)) { if (!allowFileExtensions) { // extension matched and it is not allowed if (breakOnError) { throw new IOException("Upload filename extension not allowed: " + fileNameExtension); } size = input.skipToBoundary(); return false; } return true; // extension matched and it is allowed. } } if (allowFileExtensions) { // extension is not one of the allowed ones. if (breakOnError) { throw new IOException("Upload filename extension not allowed: " + fileNameExtension); } size = input.skipToBoundary(); return false; } return true; }
@Override protected void processStream() throws IOException { if (!checkUpload()) { return;
/** * {@inheritDoc} */ @Override public FileUpload create(final MultipartRequestInputStream input) { return new AdaptiveFileUpload(input, memoryThreshold, uploadPath, maxFileSize, breakOnError, fileExtensions, allowFileExtensions); }
/** * Determines if upload is allowed. */ protected boolean checkUpload() throws IOException { if (fileExtensions != null) { if (!matchFileExtension()) { return false; } } return true; }
/** * Writes file uploaded item. */ public File write(final String destination) throws IOException { return write(new File(destination)); }