Package org.apache.commons.fileupload

Examples of org.apache.commons.fileupload.FileItemStream.openStream()


    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());
            Blob imageBlob = new Blob(resizeImage(data));
View Full Code Here


            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});
                        } else if (o instanceof String[]) {
                            String[] ss = (String[]) o;
View Full Code Here

                            FileEx[] nss = new FileEx[ss.length + 1];
                            System.arraycopy(ss, 0, nss, 0, ss.length);
                            nss[ss.length] = fileEx;
                            params.put(fis.getFieldName(), nss);
                        }
                        Streams.copy(fis.openStream(), new FileOutputStream(fileEx.getFile()), true);
                        fileEx.fileName = fis.getName();
                        fileEx.contentType = fis.getContentType();
                    }
                }
            } catch (FileUploadException e) {
View Full Code Here

        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.
                    String value = Streams.asString(stream, "UTF-8") ;
                    if ( fieldName.equals(HttpNames.paramGraph) )
View Full Code Here

    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

          memcache.put(randomId, rawData);
View Full Code Here

      byte[] rawData = null;
     
      while (i.hasNext()) {
        FileItemStream item = i.next();
        
        InputStream stream = item.openStream();
       
        byte [] content = FileUtil.toByteArray(stream);
       
        try {
          if (item.isFormField()) {  // filename         
View Full Code Here

        try {
            FileItemIterator iter = upload.getItemIterator(request);
            while (iter.hasNext() == true) {
                FileItemStream item = iter.next();
                String name = item.getName();
                InputStream stream = item.openStream();
                if (item.isFormField() == false) {
                    ContentResource child = (ContentResource)
                            dir.createChild(name, ContentNode.Type.RESOURCE);

                    File tmp = File.createTempFile("contentupload", "tmp");
View Full Code Here

            while (iter.hasNext()) {
                FileItemStream item = iter.next();

                String name = item.getFieldName();
                log("Uploaf file: " + name);
                InputStream stream = item.openStream();


                // Process the input stream
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                int len;
View Full Code Here

     
      FileItemIterator iter = upload.getItemIterator(request);
      while (iter.hasNext()) {
          FileItemStream item = iter.next();
          String name = item.getFieldName();
          InputStream stream = item.openStream();
          if (item.isFormField()) {
            String value = Streams.asString(stream);

            logger.info("Upload "+name+":"+value);
           
View Full Code Here

      try {
        FileItemIterator iter = upload.getItemIterator(request);
        while (iter.hasNext()) {
          FileItemStream item = iter.next();
          String fieldName = item.getFieldName();
          InputStream stream = item.openStream();
          if (item.isFormField()) {
            inputParams.put(fieldName, new String[] { Streams.asString(stream, Encoding.CHARSET_UTF8_NAME) });
          } else {
            fileUploads.put(fieldName, IOHelpers.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.