Hi all!

I'm working on new automatic file uploader. I need file upload for my project,
so I started looking into the util.upload.*/samples.actions.UploadFile as well
as Neeme's FileHandler.
The util.upload.* stuff depends on code that is available along with one of
O'Reily's books, and cannot be distributed with Turbine. This is not good, 
and we should think about writing free replacement for it, or removing it.

Oleg and Neeme's FileHandler is working without any additional code, but I must
say I find it a bit awkward both in programing style, and in functionality.

I have another idea of solving file uploading issues. Consider the folowing class:

public class FileItem {
   // ...
   public String getFileName();
   
   public String getContentType();

   public long getLength();

   public boolean inMemory();           // gives a hint if the file is cached or not

   public byte[] get();                 // returns the contents of the file (and 
caches it if not yet cached)

   public InputStream getStream();      // returns a stream that that can be used to 
read the file
}

Instances of such calss would be returned by 
data.getParameters().getFileItem("fieldName"); for each file
input in your form.

And the following configuration entries:

file.upload.automatic    - wether multipart/form-data request should be parsed by 
ParameterParser or 
                           left intact for Action to process

file.upload.storage      - a temporary directory for the uploaded files 

file.upload.size.max     - largest POST request that is accepted by the auto upload

file.upload.size.cache   - largest POST request which elemets will be stored in memory 
intead of disk

Caching / temporary storage management is happening behind the scenes (eg. FileItem 
deletes it's temporary
storage file inside finalize()). All turbine instances can use single temporary 
directory for uploading files
(needs turbine.instance.id patch, see my other posting today)

There is another 'bonus' feature in the code I wrote - I followed RFC 1867 
(http://rf.cx/rfc1867.html),
and implemented sending multiple files from single file input html element. No 
browsers in existence support
this, but someone could write an Applet that makes HTTP POST requests to Turbine and 
sends multiple files 
at once. Cool, isn't it?

The code will be hopefuly ready for checkin on Monday or Tuesday. 
Feedback appreciated.

Rafal


------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to