commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bohdan Bobylak (JIRA)" <j...@apache.org>
Subject [jira] Created: (FILEUPLOAD-142) ProgressListener and Streaming API improvement
Date Wed, 25 Jul 2007 16:53:31 GMT
ProgressListener  and Streaming API improvement
-----------------------------------------------

                 Key: FILEUPLOAD-142
                 URL: https://issues.apache.org/jira/browse/FILEUPLOAD-142
             Project: Commons FileUpload
          Issue Type: Improvement
    Affects Versions: 1.2
         Environment: ANY
            Reporter: Bohdan Bobylak
            Priority: Minor


This relates to the "Watching progress"  section of the FileUpload "User Guide".

As we know the ProgressListener has the only method:  void update(long pBytesRead, long pContentLength,
int pItems) ;
And it passes only:
    pBytesRead - The total number of bytes, which have been read so far.
    pContentLength - The total number of bytes, which are being read.
    pItems - The number of the field, which is currently being read.

It would be great to have access to some basic info about item currently uploaded from the
'update' method.
For example: in some cases (ex.: multipart/replace response) it is needed to skip field items
and output progress info only about file(s) being uploaded.

I think the following changes will help:
==========================================
----------------------------------------------------------
1. Introduce new interface:

interface Item {
   String 	getContentType()
   String 	getFieldName()
   String 	getName()
  boolean   isFormField() 
}
---------------------------------------------------------
2. Change (or and new) 'update' method:

void update(long pBytesRead, long pContentLength, int pItems, Item item) ;

Here we pass Item - not the FileItemSteam referense becase we should not be able to access
openStream() method of the FileItemStream.
---------------------------------------------------------
3. Change FileItemStream interface as follows:

interface FileItemStream extends Item{
   java.io.InputStream 	openStream();
}

... and change FileItemStreamImpl implementation (if needed)
----------------------------------------------------------
4. Change ProgressNotifier as follows:

static class ProgressNotifier {
    .....
    // Add this field
    private Item curItem;
    .....
    // Change the noteItem() method as follows
     void noteItem(Item item) {
              ++items;
              curItem = item;    
     }

     // Change the notifyListener() method
    private void notifyListener() {
        if (listener != null) {
            listener.update(bytesRead, contentLength, items, curItem);
        }
    }
}
--------------------------------------------------------------
5. Change calls from 'notifier.noteItem()' to 'notifier.noteItem(currentItem)' in the
    FileItemIteratorImpl.findNextItem() method of the  FileUploadBase file.
====================================

Hope my explanation of the improvement is clear.


Thank you.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message