Java Code Examples for org.apache.commons.fileupload.FileItemStream#getName()

The following examples show how to use org.apache.commons.fileupload.FileItemStream#getName() . 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 File: CloudStorageHelper.java    From getting-started-java with Apache License 2.0 6 votes vote down vote up
/**
 * Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME environment
 * variable, appending a timestamp to end of the uploaded filename.
 */
public String uploadFile(FileItemStream fileStream, final String bucketName)
    throws IOException, ServletException {
  checkFileExtension(fileStream.getName());

  System.out.println("FileStream name: " + fileStream.getName() + "\nBucket name: " + bucketName);

  DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
  DateTime dt = DateTime.now(DateTimeZone.UTC);
  String dtString = dt.toString(dtf);
  final String fileName = fileStream.getName() + dtString;

  // the inputstream is closed by default, so we don't need to close it here
  @SuppressWarnings("deprecation")
  BlobInfo blobInfo =
      storage.create(
          BlobInfo.newBuilder(bucketName, fileName)
              // Modify access list to allow all users with link to read file
              .setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
              .build(),
          fileStream.openStream());
  logger.log(
      Level.INFO, "Uploaded file {0} as {1}", new Object[] {fileStream.getName(), fileName});
  // return the public download link
  return blobInfo.getMediaLink();
}
 
Example 2
Source File: CloudStorageHelper.java    From getting-started-java with Apache License 2.0 6 votes vote down vote up
/**
 * Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME
 * environment variable, appending a timestamp to end of the uploaded filename.
 */
public String uploadFile(FileItemStream fileStream, final String bucketName)
    throws IOException, ServletException {
  checkFileExtension(fileStream.getName());

  DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
  DateTime dt = DateTime.now(DateTimeZone.UTC);
  String dtString = dt.toString(dtf);
  final String fileName = fileStream.getName() + dtString;

  // the inputstream is closed by default, so we don't need to close it here
  @SuppressWarnings("deprecation")
  BlobInfo blobInfo =
      storage.create(
          BlobInfo
              .newBuilder(bucketName, fileName)
              // Modify access list to allow all users with link to read file
              .setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
              .build(),
          fileStream.openStream());
  logger.log(Level.INFO, "Uploaded file {0} as {1}", new Object[]{
      fileStream.getName(), fileName});
  // return the public download link
  return blobInfo.getMediaLink();
}
 
Example 3
Source File: CloudStorageHelper.java    From getting-started-java with Apache License 2.0 6 votes vote down vote up
/**
 * Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME
 * environment variable, appending a timestamp to end of the uploaded filename.
 */
@SuppressWarnings("deprecation")
public String uploadFile(FileItemStream fileStream, final String bucketName)
    throws IOException, ServletException {
  checkFileExtension(fileStream.getName());

  DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
  DateTime dt = DateTime.now(DateTimeZone.UTC);
  String dtString = dt.toString(dtf);
  final String fileName = fileStream.getName() + dtString;

  // the inputstream is closed by default, so we don't need to close it here
  BlobInfo blobInfo =
      storage.create(
          BlobInfo
              .newBuilder(bucketName, fileName)
              // Modify access list to allow all users with link to read file
              .setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
              .build(),
          fileStream.openStream());
  // return the public download link
  return blobInfo.getMediaLink();
}
 
Example 4
Source File: CloudStorageHelper.java    From getting-started-java with Apache License 2.0 6 votes vote down vote up
/**
 * Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME
 * environment variable, appending a timestamp to end of the uploaded filename.
 */
public String uploadFile(FileItemStream fileStream, final String bucketName)
    throws IOException, ServletException {
  checkFileExtension(fileStream.getName());

  DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
  DateTime dt = DateTime.now(DateTimeZone.UTC);
  String dtString = dt.toString(dtf);
  final String fileName = fileStream.getName() + dtString;

  // the inputstream is closed by default, so we don't need to close it here
  @SuppressWarnings("deprecation")
  BlobInfo blobInfo =
      storage.create(
          BlobInfo
              .newBuilder(bucketName, fileName)
              // Modify access list to allow all users with link to read file
              .setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
              .build(),
          fileStream.openStream());
  // return the public download link
  return blobInfo.getMediaLink();
}
 
Example 5
Source File: WorkbenchRequest.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Map<String, String> getMultipartParameterMap()
		throws RepositoryException, IOException, FileUploadException {
	Map<String, String> parameters = new HashMap<>();
	ServletFileUpload upload = new ServletFileUpload();
	FileItemIterator iter = upload.getItemIterator(this);
	while (iter.hasNext()) {
		FileItemStream item = iter.next();
		String name = item.getFieldName();
		if ("content".equals(name)) {
			content = item.openStream();
			contentFileName = item.getName();
			break;
		} else {
			parameters.put(name, firstLine(item));
		}
	}
	return parameters;
}
 
Example 6
Source File: MultipartFormData.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public FormPart(FileItemStream stream) {
  fieldName = stream.getFieldName();
  contentType = stream.getContentType();
  binaryContent = readBinaryContent(stream);
  fileName = stream.getName();

  if(contentType == null || contentType.contains(MediaType.TEXT_PLAIN)) {
    textContent = new String(binaryContent);
  }
}
 
Example 7
Source File: Uploader.java    From jeewx with Apache License 2.0 5 votes vote down vote up
private void parseParams() {

		DiskFileItemFactory dff = new DiskFileItemFactory();
		try {
			ServletFileUpload sfu = new ServletFileUpload(dff);
			sfu.setSizeMax(this.maxSize);
			sfu.setHeaderEncoding(Uploader.ENCODEING);

			FileItemIterator fii = sfu.getItemIterator(this.request);

			while (fii.hasNext()) {
				FileItemStream item = fii.next();
				// 普通参数存储
				if (item.isFormField()) {

					this.params.put(item.getFieldName(),
							this.getParameterValue(item.openStream()));

				} else {

					// 只保留一个
					if (this.inputStream == null) {
						this.inputStream = item.openStream();
						this.originalName = item.getName();
						return;
					}

				}

			}

		} catch (Exception e) {
			this.state = this.errorInfo.get("UNKNOWN");
		}

	}
 
Example 8
Source File: StreamReceiverHandler.java    From flow with Apache License 2.0 5 votes vote down vote up
private boolean handleStream(VaadinSession session,
        StreamReceiver streamReceiver, StateNode owner, long contentLength,
        FileItemStream item) throws IOException {
    String name = item.getName();
    InputStream stream = item.openStream();
    try {
        return handleFileUploadValidationAndData(session, stream,
                streamReceiver, name, item.getContentType(), contentLength,
                owner);
    } catch (UploadException e) {
        session.getErrorHandler().error(new ErrorEvent(e));
    }
    return false;
}
 
Example 9
Source File: UploadFileStorageService.java    From actframework with Apache License 2.0 5 votes vote down vote up
private ISObject _store(FileItemStream fileItemStream) throws IOException {
    String filename = fileItemStream.getName();
    String key = newKey(filename);
    File tmpFile = getFile(key);
    InputStream input = fileItemStream.openStream();
    ThresholdingByteArrayOutputStream output = new ThresholdingByteArrayOutputStream(inMemoryCacheThreshold, tmpFile);
    IO.copy(input, output);

    ISObject retVal;
    if (output.exceedThreshold) {
        retVal = getFull(key);
    } else {
        int size = output.written;
        if (0 == size) {
            return null;
        }
        byte[] buf = output.buf();
        retVal = SObject.of(key, buf, size);
    }

    if (S.notBlank(filename)) {
        retVal.setFilename(filename);
    }
    String contentType = fileItemStream.getContentType();
    if (null != contentType) {
        retVal.setContentType(contentType);
    }
    return retVal;
}
 
Example 10
Source File: Uploader.java    From jeecg with Apache License 2.0 5 votes vote down vote up
private void parseParams() {

		DiskFileItemFactory dff = new DiskFileItemFactory();
		try {
			ServletFileUpload sfu = new ServletFileUpload(dff);
			sfu.setSizeMax(this.maxSize);
			sfu.setHeaderEncoding(Uploader.ENCODEING);

			FileItemIterator fii = sfu.getItemIterator(this.request);

			while (fii.hasNext()) {
				FileItemStream item = fii.next();
				// 普通参数存储
				if (item.isFormField()) {

					this.params.put(item.getFieldName(),
							this.getParameterValue(item.openStream()));

				} else {

					// 只保留一个
					if (this.inputStream == null) {
						this.inputStream = item.openStream();
						this.originalName = item.getName();
						return;
					}

				}

			}

		} catch (Exception e) {
			this.state = this.errorInfo.get("UNKNOWN");
		}

	}
 
Example 11
Source File: HeritFormBasedFileUtil.java    From SI with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
    * 파일을 Upload 처리한다.
    *
    * @param request
    * @param where
    * @param maxFileSize
    * @return
    * @throws Exception
    */
   public static List<HeritFormBasedFileVO> uploadFiles(HttpServletRequest request, String where, long maxFileSize) throws Exception {
List<HeritFormBasedFileVO> list = new ArrayList<HeritFormBasedFileVO>();

// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);

if (isMultipart) {
    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload();
    upload.setFileSizeMax(maxFileSize);	// SizeLimitExceededException

    // Parse the request
    FileItemIterator iter = upload.getItemIterator(request);
    while (iter.hasNext()) {
        FileItemStream item = iter.next();
        String name = item.getFieldName();
        InputStream stream = item.openStream();
        if (item.isFormField()) {
            ////System.out.println("Form field '" + name + "' with value '" + Streams.asString(stream) + "' detected.");
            Logger.getLogger(HeritFormBasedFileUtil.class).info("Form field '" + name + "' with value '" + Streams.asString(stream) + "' detected.");
        } else {
            ////System.out.println("File field '" + name + "' with file name '" + item.getName() + "' detected.");
            Logger.getLogger(HeritFormBasedFileUtil.class).info("File field '" + name + "' with file name '" + item.getName() + "' detected.");

            if ("".equals(item.getName())) {
        	continue;
            }

            // Process the input stream
            HeritFormBasedFileVO vo = new HeritFormBasedFileVO();

            String tmp = item.getName();

            if (tmp.lastIndexOf("\\") >= 0) {
        	tmp = tmp.substring(tmp.lastIndexOf("\\") + 1);
            }

            vo.setFileName(tmp);
            vo.setContentType(item.getContentType());
            vo.setServerSubPath(getTodayString());
            vo.setPhysicalName(getPhysicalFileName());

            if (tmp.lastIndexOf(".") >= 0) {
        	 vo.setPhysicalName(vo.getPhysicalName() + tmp.substring(tmp.lastIndexOf(".")));
            }

            long size = saveFile(stream, new File(HeritWebUtil.filePathBlackList(where) + SEPERATOR + vo.getServerSubPath() + SEPERATOR + vo.getPhysicalName()));

            vo.setSize(size);

            list.add(vo);
        }
    }
} else {
    throw new IOException("form's 'enctype' attribute have to be 'multipart/form-data'");
}

return list;
   }
 
Example 12
Source File: FileController.java    From cms with Apache License 2.0 4 votes vote down vote up
public void uploadFolder(HttpServletRequest request, HttpServletResponse response, String requestUri) throws WPBException
  {
org.json.JSONObject returnJson = new org.json.JSONObject();
WPBAuthenticationResult authenticationResult = this.handleAuthentication(request);
if (! isRequestAuthenticated(authenticationResult))
{
	httpServletToolbox.writeBodyResponseAsJson(response, returnJson, null, authenticationResult);
	return ;
}

      try
      {
            ServletFileUpload upload = new ServletFileUpload();
            upload.setHeaderEncoding("UTF-8");
            FileItemIterator iterator = upload.getItemIterator(request);
            WPBFile ownerFile = null;
            Map<String, WPBFile> subfolderFiles = new HashMap<String, WPBFile>();
            
            while (iterator.hasNext()) {
              FileItemStream item = iterator.next();
             
              if (item.isFormField() && item.getFieldName().equals("ownerExtKey"))
              {
                  String ownerExtKey = Streams.asString(item.openStream());
                  ownerFile = getDirectory(ownerExtKey, adminStorage);	            
              } else
              if (!item.isFormField() && item.getFieldName().equals("file")) {
                
                String fullName = item.getName();
                String directoryPath = getDirectoryFromLongName(fullName);
                String fileName = getFileNameFromLongName(fullName);
                
                Map<String, WPBFile> tempSubFolders = checkAndCreateSubDirectory(directoryPath, ownerFile);
                subfolderFiles.putAll(tempSubFolders);
                
                // delete the existing file
                WPBFile existingFile = getFileFromDirectory(subfolderFiles.get(directoryPath) , fileName);
                if (existingFile != null)
                {
                    deleteFile(existingFile, 0);
                }
                
                // create the file
                WPBFile file = new WPBFile();
                file.setExternalKey(adminStorage.getUniqueId());
                file.setFileName(fileName);
                file.setLastModified(Calendar.getInstance(TimeZone.getTimeZone("GMT")).getTime());
                file.setDirectoryFlag(0);
                
                addFileToDirectory(subfolderFiles.get(directoryPath), file, item.openStream());
                
              }
            } 
            
            returnJson.put(DATA, jsonObjectConverter.JSONFromObject(null));           
               httpServletToolbox.writeBodyResponseAsJson(response, returnJson, null, authenticationResult);
      } catch (Exception e)
      {
          Map<String, String> errors = new HashMap<String, String>();     
          errors.put("", WPBErrors.WB_CANT_UPDATE_RECORD);
          httpServletToolbox.writeBodyResponseAsJson(response, jsonObjectConverter.JSONObjectFromMap(null), errors);          
      }
  }
 
Example 13
Source File: CmisController.java    From studio with GNU General Public License v3.0 4 votes vote down vote up
@PostMapping(value = "/api/2/cmis/upload")
public ResponseBody uploadContent(HttpServletRequest httpServletRequest)
        throws IOException, CmisUnavailableException, CmisPathNotFoundException, CmisTimeoutException,
        CmisRepositoryNotFoundException, FileUploadException, InvalidParametersException {

    ServletFileUpload servletFileUpload = new ServletFileUpload();
    FileItemIterator itemIterator = servletFileUpload.getItemIterator(httpServletRequest);
    String filename = StringUtils.EMPTY;
    String siteId = StringUtils.EMPTY;
    String cmisRepoId = StringUtils.EMPTY;
    String cmisPath = StringUtils.EMPTY;
    CmisUploadItem cmisUploadItem = new CmisUploadItem();
    while (itemIterator.hasNext()) {
        FileItemStream item = itemIterator.next();
        String name = item.getFieldName();
        try (InputStream stream = item.openStream()) {
            if (item.isFormField()) {
                switch (name) {
                    case REQUEST_PARAM_SITEID:
                        siteId = Streams.asString(stream);
                        break;
                    case REQUEST_PARAM_CMIS_REPO_ID:
                        cmisRepoId = Streams.asString(stream);
                        break;
                    case REQUEST_PARAM_CMIS_PATH:
                        cmisPath = Streams.asString(stream);
                        break;
                    default:
                        // Unknown parameter, just skip it...
                        break;
                }
            } else {
                filename = item.getName();
                if (StringUtils.isEmpty(siteId)) {
                    throw new InvalidParametersException("Invalid siteId");
                }
                if (StringUtils.isEmpty(cmisRepoId)) {
                    throw new InvalidParametersException("Invalid cmisRepoId");
                }
                if (StringUtils.isEmpty(cmisPath)) {
                    throw new InvalidParametersException("Invalid cmisPath");
                }
                cmisUploadItem = cmisService.uploadContent(siteId, cmisRepoId, cmisPath, filename, stream);
            }
        }
    }
    ResponseBody responseBody = new ResponseBody();
    ResultOne<CmisUploadItem> result = new ResultOne<CmisUploadItem>();
    result.setResponse(OK);
    result.setEntity(RESULT_KEY_ITEM, cmisUploadItem);
    responseBody.setResult(result);
    return responseBody;
}
 
Example 14
Source File: AwsS3Controller.java    From studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Upload a file to an S3 bucket.
 * @param request the request
 * @return the item uploaded
 * @throws IOException if there is any error reading the content of the file
 * @throws InvalidParametersException if there is any error parsing the request
 * @throws AwsException if there is any error connecting to S3
 */
@PostMapping("/upload")
public ResultOne<S3Item> uploadItem(HttpServletRequest request) throws IOException, InvalidParametersException,
    AwsException {
    if(ServletFileUpload.isMultipartContent(request)) {
        ResultOne<S3Item> result = new ResultOne<>();
        try {
            ServletFileUpload upload = new ServletFileUpload();
            FileItemIterator iterator = upload.getItemIterator(request);
            String siteId = null;
            String profileId = null;
            String path = null;
            while (iterator.hasNext()) {
                FileItemStream item = iterator.next();
                String name = item.getFieldName();
                try(InputStream stream = item.openStream()) {
                    if (item.isFormField()) {
                        switch (name) {
                            case REQUEST_PARAM_SITEID:
                                siteId = Streams.asString(stream);
                                break;
                            case REQUEST_PARAM_PROFILE_ID:
                                profileId = Streams.asString(stream);
                                break;
                            case REQUEST_PARAM_PATH:
                                path = Streams.asString(stream);
                            default:
                                // Unknown parameter, just skip it...
                        }
                    } else {
                        String filename = item.getName();
                        if (StringUtils.isNotEmpty(filename)) {
                            filename = FilenameUtils.getName(filename);
                        }
                        result.setEntity(RESULT_KEY_ITEM,
                            s3Service.uploadItem(siteId, profileId, path, filename, stream));
                        result.setResponse(ApiResponse.OK);
                    }
                }
            }
            return result;
        } catch (FileUploadException e) {
            throw new InvalidParametersException("The request body is invalid");
        }
    } else {
        throw new InvalidParametersException("The request is not multipart");
    }
}
 
Example 15
Source File: AwsMediaConvertController.java    From studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Uploads a file to S3 and triggers a MediaConvert job
 *
 * @param request the request
 * @return the result of triggering the job
 * @throws IOException if there is any error reading the content of the file
 * @throws AwsException if there is any error uploading the file or triggering the job
 * @throws InvalidParametersException if there is any error parsing the request
 */
@PostMapping("/upload")
public ResultOne<MediaConvertResult> uploadVideo(HttpServletRequest request)
    throws IOException, AwsException, InvalidParametersException {
    if (ServletFileUpload.isMultipartContent(request)) {
        ResultOne<MediaConvertResult> result = new ResultOne<>();
        try {
            ServletFileUpload upload = new ServletFileUpload();
            FileItemIterator iterator = upload.getItemIterator(request);
            String siteId = null;
            String inputProfileId = null;
            String outputProfileId = null;
            while (iterator.hasNext()) {
                FileItemStream item = iterator.next();
                String name = item.getFieldName();
                try (InputStream stream = item.openStream()) {
                    if (item.isFormField()) {
                        switch (name) {
                            case REQUEST_PARAM_SITEID:
                                siteId = Streams.asString(stream);
                                break;
                            case INPUT_PROFILE_PARAM:
                                inputProfileId = Streams.asString(stream);
                                break;
                            case OUTPUT_PROFILE_PARAM:
                                outputProfileId = Streams.asString(stream);
                                break;
                            default:
                                // Unknown parameter, just skip it...
                        }
                    } else {
                        if (StringUtils.isAnyEmpty(siteId, inputProfileId, outputProfileId)) {
                            throw new InvalidParametersException("Missing one or more required parameters: "
                                + "siteId, inputProfileId or outputProfileId");
                        }
                        String filename = item.getName();
                        if (StringUtils.isNotEmpty(filename)) {
                            filename = FilenameUtils.getName(filename);
                        }
                        result.setEntity(RESULT_KEY_ITEM,
                            mediaConvertService
                                .uploadVideo(siteId, inputProfileId, outputProfileId, filename, stream));
                        result.setResponse(ApiResponse.OK);
                    }
                }
            }
            return result;
        } catch (FileUploadException e) {
            throw new InvalidParametersException("The request body is invalid");
        }
    } else {
        throw new InvalidParametersException("The request is not multipart");
    }
}
 
Example 16
Source File: WebdavController.java    From studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Uploads a file to a WebDAV server
 * @param request the request
 * @return the uploaded item
 * @throws IOException if there is any error reading the content of the file
 * @throws WebDavException if there is any error uploading the file to the WebDAV server
 * @throws InvalidParametersException if there is any error parsing the request
 */
@PostMapping("/upload")
public ResultOne<WebDavItem> uploadItem(HttpServletRequest request) throws IOException, WebDavException,
    InvalidParametersException {
    if (ServletFileUpload.isMultipartContent(request)) {
        ResultOne<WebDavItem> result = new ResultOne<>();
        try {
            ServletFileUpload upload = new ServletFileUpload();
            FileItemIterator iterator = upload.getItemIterator(request);
            String siteId = null;
            String profileId = null;
            String path = null;
            if (!iterator.hasNext()) {
                throw new InvalidParametersException("Request body is empty");
            }
            while (iterator.hasNext()) {
                FileItemStream item = iterator.next();
                String name = item.getFieldName();
                try(InputStream stream = item.openStream()) {
                    if (item.isFormField()) {
                        switch (name) {
                            case REQUEST_PARAM_SITEID:
                                siteId = Streams.asString(stream);
                                break;
                            case REQUEST_PARAM_PROFILE_ID:
                                profileId = Streams.asString(stream);
                                break;
                            case REQUEST_PARAM_PATH:
                                path = Streams.asString(stream);
                            default:
                                // Unknown parameter, just skip it...
                        }
                    } else {
                        String filename = item.getName();
                        if (StringUtils.isNotEmpty(filename)) {
                            filename = FilenameUtils.getName(filename);
                        }
                        result.setEntity(RESULT_KEY_ITEM,
                            webDavService.upload(siteId, profileId, path, filename, stream));
                        result.setResponse(ApiResponse.OK);
                    }
                }
            }
            return result;
        } catch (FileUploadException e) {
            throw new InvalidParametersException("The request body is invalid");
        }
    } else {
        throw new InvalidParametersException("The request is not multipart");
    }
}
 
Example 17
Source File: HeritFormBasedFileUtil.java    From SI with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
    * 파일을 Upload 처리한다.
    *
    * @param request
    * @param where
    * @param maxFileSize
    * @return
    * @throws Exception
    */
   public static List<HeritFormBasedFileVO> uploadFiles(HttpServletRequest request, String where, long maxFileSize) throws Exception {
List<HeritFormBasedFileVO> list = new ArrayList<HeritFormBasedFileVO>();

// Check that we have a file upload request
boolean isMultipart = ServletFileUpload.isMultipartContent(request);

if (isMultipart) {
    // Create a new file upload handler
    ServletFileUpload upload = new ServletFileUpload();
    upload.setFileSizeMax(maxFileSize);	// SizeLimitExceededException

    // Parse the request
    FileItemIterator iter = upload.getItemIterator(request);
    while (iter.hasNext()) {
        FileItemStream item = iter.next();
        String name = item.getFieldName();
        InputStream stream = item.openStream();
        if (item.isFormField()) {
            ////System.out.println("Form field '" + name + "' with value '" + Streams.asString(stream) + "' detected.");
            Logger.getLogger(HeritFormBasedFileUtil.class).info("Form field '" + name + "' with value '" + Streams.asString(stream) + "' detected.");
        } else {
            ////System.out.println("File field '" + name + "' with file name '" + item.getName() + "' detected.");
            Logger.getLogger(HeritFormBasedFileUtil.class).info("File field '" + name + "' with file name '" + item.getName() + "' detected.");

            if ("".equals(item.getName())) {
        	continue;
            }

            // Process the input stream
            HeritFormBasedFileVO vo = new HeritFormBasedFileVO();

            String tmp = item.getName();

            if (tmp.lastIndexOf("\\") >= 0) {
        	tmp = tmp.substring(tmp.lastIndexOf("\\") + 1);
            }

            vo.setFileName(tmp);
            vo.setContentType(item.getContentType());
            vo.setServerSubPath(getTodayString());
            vo.setPhysicalName(getPhysicalFileName());

            if (tmp.lastIndexOf(".") >= 0) {
        	 vo.setPhysicalName(vo.getPhysicalName() + tmp.substring(tmp.lastIndexOf(".")));
            }

            long size = saveFile(stream, new File(HeritWebUtil.filePathBlackList(where) + SEPERATOR + vo.getServerSubPath() + SEPERATOR + vo.getPhysicalName()));

            vo.setSize(size);

            list.add(vo);
        }
    }
} else {
    throw new IOException("form's 'enctype' attribute have to be 'multipart/form-data'");
}

return list;
   }