Package org.apache.commons.fileupload

Examples of org.apache.commons.fileupload.ProgressListener


        List<FileItem> items = null;
        /** The parameters other than accessKey, UserId, Action. */
        HashMap<String, String> parameterMap = new HashMap<String, String>();
        // Create a progress listener on server side; pretty useless, so far but
        // when pushed to client can be nice.
        ProgressListener progressListener = new ProgressListener() {
            private long batchesRead = -1; // Currently read.
            private long bytesPerBatch = 100 * 1024; // 10 k incremental report

            // increase when done
            // testing.
View Full Code Here


       
        DiskFileItemFactory fileItemFactory = new DiskFileItemFactory();
        fileItemFactory.setFileCleaningTracker(new FileCleaningTracker());
       
        ServletFileUpload upload = new ServletFileUpload(fileItemFactory);
        upload.setProgressListener(new ProgressListener() {
            boolean setContentLength = false;
            long lastBytesRead = 0;
           
            @Override
            public void update(long bytesRead, long contentLength, int itemCount) {
View Full Code Here

        factory.setRepository(uploadDir);

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        upload.setHeaderEncoding("UTF-8");
        ProgressListener listener = new ProgressListener() {
            public void update(long pBytesRead, long pContentLength, int pItems) {
                if (pBytesRead == upResource.getUploadedSize())
                    return;
                upResource.addUploadedBytes(pBytesRead - upResource.getUploadedSize());
            }
View Full Code Here

        factory.setRepository(new File(uploadLocation_));

        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        upload.setHeaderEncoding("UTF-8");
        ProgressListener listener = new ProgressListener() {
            public void update(long pBytesRead, long pContentLength, int pItems) {
                if (pBytesRead == upResource.getUploadedSize())
                    return;
                upResource.addUploadedBytes(pBytesRead - upResource.getUploadedSize());
            }
View Full Code Here

      // Create a new file upload handler
      ServletFileUpload upload = new ServletFileUpload(factory);

      //Create a progress listener
      ProgressListener progressListener = new ProgressListener(){
         public void update(long pBytesRead, long pContentLength, int pItems) {
             System.out.println("We are currently reading item " + pItems);
             if (pContentLength == -1) {
                 System.out.println("So far, " + pBytesRead + " bytes have been read.");
             } else {
View Full Code Here

    // Get the request ID
    final String requestId = request.getParameter("requestId");

    // Create a progress listener
    ProgressListener progressListener = new ProgressListener() {
      private long lastNotification = 0;

      public void update(long pBytesRead, long pContentLength, int pItems) {
        if (lastNotification == 0 || (pBytesRead - lastNotification) > NOTIFICATION_THRESHOLD) {
          lastNotification = pBytesRead;
View Full Code Here

    status.setStatus(FileUploadStatus.UPLOADING);
    BaseService.fileUploadStatusMap.put(user, status);

    // If file size exceeds, a FileUploadException will be thrown
    fu.setSizeMax(268435456);
    fu.setProgressListener(new ProgressListener() {
      public void update(long bytesRead, long contentLength, int item) {
        status.setItem(item);
        status.setBytesRead(bytesRead);
        status.setContentLength(contentLength);
        status.setStatus(FileUploadStatus.UPLOADING);
View Full Code Here

      factory.setRepository(new File(uploadLocation_));

      // Create a new file upload handler
      ServletFileUpload upload = new ServletFileUpload(factory);
      upload.setHeaderEncoding("UTF-8");
      ProgressListener listener = new ProgressListener()
      {
         public void update(long pBytesRead, long pContentLength, int pItems)
         {
            if (pBytesRead == upResource.getUploadedSize())
               return;
View Full Code Here

      factory.setRepository(new File(uploadLocation_));

      // Create a new file upload handler
      ServletFileUpload upload = new ServletFileUpload(factory);
      upload.setHeaderEncoding("UTF-8");
      ProgressListener listener = new ProgressListener()
      {
         public void update(long pBytesRead, long pContentLength, int pItems)
         {
            if (pBytesRead == upResource.getUploadedSize())
               return;
View Full Code Here

            ServletFileUpload upload = new ServletFileUpload(factory);

            String targetDirectory = null;
            List<File> files = new ArrayList<File>();

            upload.setProgressListener(new ProgressListener() {

                private long mBytesRead = 0;

                @Override
                public void update(long pBytesRead, long pContentLength, int pItems) {
View Full Code Here

TOP

Related Classes of org.apache.commons.fileupload.ProgressListener

Copyright © 2018 www.massapicom. 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.