That's kinda cool, but I have a question... How would such a thing work in
a clustered environment?

I may not understand some things about your solution, so feel free to
correct me on any points I get wrong, but...

I presume a browser starts an upload and you simultaneously open a new
window that will periodically communicate with this monitor class to check
the status of the file being uploaded.  Do I have at least THAT much
right?? :)

Assuming so... in a clustered environment, first of all, writing to the
file system is generally discouraged practice (although it can be done
safely, so let's ignore what might be best practice for the moment)... but
if you do so, since the upload may start on one server and then the
monitor gets executed on any server in the cluster with each subsequent
check operation, how does that get handled?

The only answer I can think of is to assume that each server in the
cluster has a mapping to some common shared drive where the uploads are
written to, but that is assuming something about the deployment
environment, and something I know for sure would never happen where I
work.

How do you propose handling that?  Of course, if I got something wrong, as
i said, it's maybe a moot question :)

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Mon, March 7, 2005 2:52 pm, Dakota Jack said:
> Yes, this is possible and an interface for doing that is given my my
> presentation on the wiki.  If you look at the classes and where
> (Monitor)iter.next() occurs in the UploadFileItem class, etc. you will
> see how to implement such monitors generally.  If you are interested,
> the implementation I use to monitor the upload is:
>
> public class UploadMonitorProgress
>     implements Monitor {
>   private           File        tempFile        = null;
>   private           boolean     uploaded        = false;
>   private           boolean     cancelled       = false;
>   private           int         accumulatedSize = -1;
>   private           int         size            = -1;
>   private           int         totalSize       = -1;
>   private           int         fileNumber      = 0;
>
>   public UploadMonitorProgress() {
>   }
>
>   public void init(File   tempFile,
>                    int    totalSize,
>                    String contentType) {
>     this.tempFile  = tempFile;
>     this.totalSize = totalSize;
>     this.uploaded  = false;
>     this.cancelled = false;
>     this.size      = 0;
>     this.fileNumber++;
>   }
>
>   public void notify(UploadParams up,
>                      MultipartFile file) {
>     uploaded = true;
>   }
>
>   public void read(int read) {
>     size            += read;
>     accumulatedSize += read;
>   }
>
>   public boolean isFileUploaded() {
>     return uploaded;
>   }
>
>   public boolean isFileUploadCancelled() {
>     return cancelled;
>   }
>
>   public int getUploadedKBLength() {
>     int kbLength = Math.round(size * 1.0f / 1024.0f);
>     return kbLength;
>   }
>
>   public int getUploadedLength() {
>     return size;
>   }
>
>   public int getFileUploadedRatio() {
>     if (totalSize > 0) {
>       int ratio = (int) Math.round(accumulatedSize * 100.0f / totalSize *
> 1.0f);
>       return ratio;
>     } else {
>       return 0;
>     }
>   }
>
>   public int getTotalUploadedRatio() {
>     if (totalSize > 0) {
>       int ratio = (int) Math.round(accumulatedSize * 100.0f / totalSize *
> 1.0f);
>       return ratio;
>     } else {
>       return 0;
>     }
>   }
>
>   public int getFileNumber() {
>     return fileNumber;
>   }
>
>   public int getAccumulatedSize() {
>     return accumulatedSize;
>   }
>
>   public int getTotalLength() {
>     return totalSize;
>   }
>
>   public void cancel() {
>     this.cancelled = true;
>   }
>
>   public void reset() {
>     cleanLastUpload();
>     tempFile        = null;
>     totalSize       = -1;
>     uploaded        = false;
>     cancelled       = false;
>     size            = -1;
>     accumulatedSize = -1;
>     fileNumber      = 0;
>   }
>
>   public void cleanLastUpload() {
>      if (tempFile != null) {
>        String tmpFileName = tempFile.getName();
>        tempFile.delete();
>      }
>   }
> }
>
> Does this help?
>
> On Mon, 7 Mar 2005 19:37:41 +0100, Leon Rosenberg
> <[EMAIL PROTECTED]> wrote:
>> <2cents>
>
>> Another nice feature would be a monitor, which can inform the client
>> about
>> current progress,
>> like in a javascript application.
>>
>> I'm not sure whether the first is possible with the current jsp/servlet
>> spec, but the second feature
>> should be possible, and is very useful.
>> </2cents>
>>
>> Regards
>> Leon
>>
>> > -----Ursprüngliche Nachricht-----
>> > Von: Dakota Jack [mailto:[EMAIL PROTECTED]
>> > Gesendet: Montag, 7. März 2005 17:47
>> > An: Struts Users Mailing List
>> > Betreff: DownloadAction Application
>> >
>> > I am presently beginning to code a download application to go
>> > with my upload application
>> > (http://wiki.apache.org/struts/StrutsUpload) in Struts,
>> > although I am not initially trying to combine them.  That
>> > will be a part of refactoring.  Does anyone have any code or
>> > ideas out there they would suggest is the "cat's meow" on
>> > this?  Any "gotchas"
>> > that need to be watched?
>> >
>> > Thanks!
>> >
>> > Jack
>> >
>> > --
>> > "You can lead a horse to water but you cannot make it float
>> > on its back."
>> > ~Dakota Jack~
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
> --
> "You can lead a horse to water but you cannot make it float on its back."
> ~Dakota Jack~
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to