struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dakota Jack <dakota.j...@gmail.com>
Subject Re: AW: AW: DownloadAction Application
Date Mon, 07 Mar 2005 20:08:04 GMT
Just as an additional note, the threshold in the commons fileupload
determines when things are written to file, etc. rather than to memory
and can be used for various efficiencies.

Jack


On Mon, 7 Mar 2005 12:05:49 -0800, Dakota Jack <dakota.jack@gmail.com> wrote:
> Yes, it does, sort of.  Check ThresholdingOutputStream and
> DeferredFileOutputStream.   My UploadOutputStream overrides the
> write(byte data[], int i, int j) method to monitor the upload.  Once
> you have the hook of the monitor variable in the upload process, you
> can do whatever you like during the read.  The Monitor class is, as
> you can see from the wiki, an interface and the code given below does
> not insert a monitor but a List of monitors into the process.  You can
> do lots of things with this: cut the upload off, monitor the upload,
> send emails, read protocols and their relation to file extensions,
> etc.  This is what I have been trying to make possible, among other
> things, while using ActionForm as well as Action in Struts v1.3 and
> following.
> 
> Pretty cool, eh?
> 
> public class UploadOutputStream
>     extends DeferredFileOutputStream {
>   private List  monitors;
>   private boolean isFormField;
> 
>   public UploadOutputStream(int     threshold,
>                             File    outputFile,
>                             List    monitors,
>                             boolean isFormField) {
>     super(threshold, outputFile);
>     this.monitors = monitors;
>     this.isFormField = isFormField;
>   }
> 
>   public void write(byte data[], int i, int j)
>       throws IOException {
>     super.write(data, i, j);
>     if((monitors != null) && (! isFormField)) {
>       Iterator iter = monitors.iterator();
>       while(iter.hasNext()) {
>         ((Monitor)iter.next()).read(j);
>       }
>     }
>   }
> }
> 
> <SNIP>
> On Mon, 7 Mar 2005 14:28:37 -0500 (EST), Frank W. Zammetti
> <fzlists@omnytex.com> wrote:
> > I'd be willing to bet Commons does the same thing, but I don't know for
> > sure.  Anyone reading this able to illuminate us?
> </SNIP>
> --
> "You can lead a horse to water but you cannot make it float on its back."
> ~Dakota Jack~
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message