Examples of FileItemIterator


Examples of org.apache.commons.fileupload.FileItemIterator

      throws FileUploadException
    {
    try
    {
      RequestContext ctx = new ServletRequestContext(request);
        FileItemIterator iter = fileUpload.getItemIterator(ctx);
        //List<FileItem> items = new ArrayList<FileItem>();
        String filenames = "";
        String[] overrideFilenames = request.getParameterValues("overrideFilenames");
        String overrideFilename;
        int i = 0;
       
        while (iter.hasNext())
        {
            FileItemStream item = iter.next();
            LOG.finest("The filename from the browser is: "+item.getName());
         
          if(overrideFilenames == null || overrideFilenames.length >= i || overrideFilenames[i] == null)
          {
            overrideFilename = item.getName();
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

    protected void doPost(final HttpServletRequest request,
                          final HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        final ServletFileUpload upload = new ServletFileUpload();
        FileItemIterator iterator = null;

        try {
            iterator = upload.getItemIterator(request);

            while (iterator.hasNext()) {
                final FileItemStream item = iterator.next();
                final InputStream stream = item.openStream();

                final JSONObject preference = preferenceUtils.getPreference();
                if (null == preference) {
                    response.sendError(HttpServletResponse.SC_NOT_FOUND);
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

    }

  @Override
  public List<FileItem> parseRequest(RequestContext ctx) throws FileUploadException {
     try {
         FileItemIterator iter = getItemIterator(ctx);
         List<FileItem> items = new ArrayList<FileItem>();
         FileItemFactory fac = getFileItemFactory();
         if (fac == null) {
             throw new NullPointerException(
                 "No FileItemFactory has been set.");
         }
         while (iter.hasNext()) {
             FileItemStream item = iter.next();
             HttpFileItem fileItem = new HttpFileItem(fac.createItem(item.getFieldName(),
                     item.getContentType(), item.isFormField(),
                     item.getName())
             );
             try {
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

        // check multipart
        isMultipart = ServletFileUpload.isMultipartContent(request);

        if (isMultipart) {
            ServletFileUpload upload = new ServletFileUpload();
            FileItemIterator iter = upload.getItemIterator(request);

            while (iter.hasNext()) {
                FileItemStream item = iter.next();
                String name = item.getFieldName();
                InputStream itemStream = new BufferedInputStream(item.openStream());

                if (item.isFormField()) {
                    InputStreamReader reader = new InputStreamReader(itemStream, "UTF-8");
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

        this.formItems = new HashMap<String, List<String>>();

        ServletFileUpload upload = new ServletFileUpload();
        upload.setFileSizeMax(maxFileSize);
        try {
            FileItemIterator it = upload.getItemIterator(target);
            while (it.hasNext()) {
                FileItemStream item = it.next();
                if (item.isFormField()) {
                    InputStream input = null;
                    try {
                        input = item.openStream();
                        String fieldName = item.getFieldName();
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

    log.info("Uploading a file");
    Map<String, Blob> images = new LinkedHashMap<String, Blob>();
    // Get the image representation
    try{
        ServletFileUpload upload = new ServletFileUpload();
        FileItemIterator iter = upload.getItemIterator(req);
        while(iter.hasNext()){
          FileItemStream imageItem = iter.next();
          InputStream imgStream = imageItem.openStream();
          byte[] data = IOUtils.toByteArray(imgStream);
          imgStream.close();
          if(!imageItem.isFormField() && data.length>0){
            log.info("Is a file: "+imageItem.getName());
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

            }
            if (cfg.getFileUploadFileSizeMax() != 0) {
                fileUpload.setFileSizeMax(cfg.getFileUploadFileSizeMax());
            }
            try {
                FileItemIterator it = fileUpload.getItemIterator(request);
                while (it.hasNext()) {
                    FileItemStream fis = it.next();
                    if (fis.isFormField()) {
                        String s = Streams.asString(fis.openStream(), cfg.getCharset());
                        Object o = params.get(fis.getFieldName());
                        if (o == null) {
                            params.put(fis.getFieldName(), new String[]{s});
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

        ContentType ct = null ;
        Lang lang = null ;
        int tripleCount = 0 ;

        try {
            FileItemIterator iter = upload.getItemIterator(action.request);
            while (iter.hasNext()) {
                FileItemStream item = iter.next();
                String fieldName = item.getFieldName();
                InputStream stream = item.openStream();
                if (item.isFormField())
                {
                    // Graph name.
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    // Create a new file upload handler
    String resultStr = null;
   
    try {
      FileItemIterator i = new ServletFileUpload().getItemIterator(req);

      while (i.hasNext()) {
        FileItemStream item = i.next();
        InputStream stream = item.openStream();
        try {
          String randomId = UUID.randomUUID().toString()// cache ID
          byte[] rawData = FileUtil.toByteArray(stream)// cache data
View Full Code Here

Examples of org.apache.commons.fileupload.FileItemIterator

  protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    String resultStr = null;
   
    // Create a new file upload handler
    try {
      FileItemIterator i = new ServletFileUpload().getItemIterator(req);

      // step1 : extract data from the request
      String fileName = null;
      byte[] rawData = null;
     
      while (i.hasNext()) {
        FileItemStream item = i.next();
        
        InputStream stream = item.openStream();
       
        byte [] content = FileUtil.toByteArray(stream);
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.