Hi Michael, I don't understand you're proposal. FileItem (from commons upload) is an interface with a factory. FileUploadBase (the parser) is abstract with different implementations. Why would you wrap the interface instead of simply creating a new concrete implementation of the above mentioned classes?
In addition, I'm not sure I understand the dilemma of any of this. If commons-upload didn't suite your needs, you could easy create an abstract Action for multipart forms that is similar to the following: public abstract MyMultipartActionSupport extends Action { public final execute(mapping, form, request, response) { // parse request into MyFileItems List items = MyParser.parse(request); executeWithFileItems(mapping, form, request, response, items); } public abstract executeWithFileItems(mapping, form, request, response, items); } This allows you to still use Struts Actions and use anything you want to parse the multipart form. Remember the FileItem / Upload packages are convenience wrappers around parsing this stuff from the request. You could even get crazy and add the special "file upload parser" implementation class name to your action config parameter, giving you all the flexibility you dreamed. But perhaps I'm missing something. - Mike P.S. What would you want to do that the commons file upload doesn't give you? On Tue, 2004-10-05 at 03:20, Michael McGrady wrote: > For anyone interested in an option, what I would like to do is given > below. Anyone have any suggestions on the best way to do this and still > use ActionForm, short of rewriting ActionForm? Thanks for any > assistance. (The UploadFileItem is just a simple Serialized wrapper of > commons' FileItem. This wrapper utilizes a buffered input stream.) > > > public class UploadParser { > > public UploadParser() { > } > > public void parse(HttpServletRequest req, > Vector uploadListeners, > int fileSizeLimit, > Hashtable parameters, > Hashtable files, > String tmpFolder, > String encoding) > throws IOException { > DiskFileUpload dfu = new DiskFileUpload(); > dfu.setSizeMax(fileSizeLimit); > dfu.setSizeThreshold(UploadConstant.MEMORY_BUFFER_SIZE); > dfu.setRepositoryPath(tmpFolder); > if(encoding != null) { > dfu.setHeaderEncoding(encoding); > } > List list = null; > try { > list = dfu.parseRequest(req); > } catch(FileUploadException fue) { > throw new IOException(fue.getMessage()); > } > Object obj = null; > for(Iterator iter = list.iterator(); iter.hasNext();) { > FileItem fi = (FileItem)iter.next(); > String fieldName = fi.getFieldName(); > if(fi.isFormField()) { > String holder = null; > if(encoding != null) { > holder = fi.getString(encoding); > } else { > holder = fi.getString(); > } > Vector params = (Vector)parameters.get(fieldName); > if(params == null) { > params = new Vector(); > parameters.put(fieldName, params); > } > params.addElement(holder); > } else { > String fin = fi.getName(); > > if(fin != null) { > UploadFileItem ufi = new UploadFileItem(fi); > fin = fin.replace('\\', '/'); > int j = fin.lastIndexOf("/"); > if(j != -1) { > fin = fin.substring(j + 1, fin.length()); > } > ufi.setFileName(fin); > ufi.setContentType(fi.getContentType()); > ufi.setFileSize(fi.getSize()); > files.put(fieldName, ufi); > } > } > } > } > } > > public class UploadFileItem > implements Serializable { > private FileItem fi; > private String contentType; > private String fileName; > private long fileSize; > > > public UploadFileItem() { this.fi = null; } > public UploadFileItem(FileItem fi) { this.fi = fi; } > > public FileItem getFileItem() { return fi; } > public long getFileSize() { return > fileSize; } > public String getFileName() { return > fileName; } > public String getContentType() { return > contentType; } > > public void setFileSize(long fileSize) { this.fileSize > = fileSize; } > public void setFileName(String fileName) { this.fileName > = fileName; } > public void setContentType(String contentType) { > this.contentType = contentType; } > > public InputStream getInputStream() { > if(fi == null) { > return null; > } > > InputStream is = null; > try { > is = new BufferedInputStream(fi.getInputStream()); > } catch (IOException ioe) { > StdOut.log("log.error",ioe.getMessage()); > } > return is; > } > > public byte[] getData() { > InputStream is = getInputStream(); > if(is != null) { > int i = (int)getFileSize(); > if(i > 0) { > byte data[] = new byte[i]; > try { > is.read(data); > is.close(); > } catch(IOException ioe) { } > return data; > } else { > return null; > } > } else { > return null; > } > } > > public void reset() { > if(fi != null) { > fi.delete(); > } > } > }