DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22497>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22497

Add write() method or change method accessibility on CommonsMultipartRequestHandler

           Summary: Add write() method or change method accessibility on
                    CommonsMultipartRequestHandler
           Product: Struts
           Version: 1.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: File Upload
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


org.apache.commons.fileupload.FileItem has a very useful write(File) method to
write the uploaded file to a final destination (it's intelligent in it's
implementation too).

In the absence of this in CommonsMultipartRequestHandler.CommonsFormFile I went
about extending CommonsMultipartRequestHandler to add it - but the nested class
and various methods within CommonsMultipartRequestHandler make this impossible
(without copying lots of code). Would it be possible to add the write() method
or possibly a better option - at least make the class extensible.

Below is an example of what I'm trying to do: (any suggestions on any better
alternatives would also be welcomed :-) ).

package eduni.inf.upload;

import org.apache.struts.upload.CommonsMultipartRequestHandler;
import org.apache.struts.upload.FormFile;
import org.apache.commons.fileupload.FileItem;


public class EnhancedCommonsMultipartRequestHandler
    extends CommonsMultipartRequestHandler {

    protected void addFileParameter(FileItem item) {
        FormFile formFile = new EnhancedCommonsFormFile(item);

        elementsFile.put(item.getFieldName(), formFile);
        elementsAll.put(item.getFieldName(), formFile);
    }

    static class EnhancedCommonsFormFile extends CommonsFormFile {

        public EnhancedCommonsFormFile(FileItem fileItem) {
            super(fileItem);
        }

        public void write(java.io.File file)
           throws java.lang.Exception {

            fileItem.write(file);
        }
    }

}

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

Reply via email to