-- James Mitchell Software Engineer / Open Source Evangelist EdgeTech, Inc. 678.910.8017 AIM: jmitchtx
----- Original Message ----- From: <dev@struts.apache.org>
To: <dev@struts.apache.org>
Sent: Saturday, March 05, 2005 6:30 PM
Subject: [Apache Struts Wiki] Updated: StrutsUpload
Date: 2005-03-05T15:30:46 Editor: DakotaJack Wiki: Apache Struts Wiki Page: StrutsUpload URL: http://wiki.apache.org/struts/StrutsUpload
no comment
Change Log:
------------------------------------------------------------------------------ @@ -1,5 +1,50 @@ == Overview ==
+Utilizing the sort of structure suggested for Struts upload below allows us to have an !ActionUpload class as follows:
+
+(This is actual code used in a working application online.)
+
+{{{
+public class UploadAction
+ extends Action {
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest req,
+ HttpServletResponse res)
+ throws Exception {
+ HttpSession sess = req.getSession();
+ Upload upload = (Upload)sess.getAttribute(UploadConstant.UPLOAD);
+
+ if(upload == null) {
+ upload = new Upload();
+ sess.setAttribute(UploadConstant.UPLOAD,upload);
+ }
+
+ if(upload.isMultipart(req)) {
+ Monitor progress = (UploadMonitorProgress)sess.getAttribute(UploadConstant.MONITOR);
+
+ if(progress == null) {
+ progress = new UploadMonitorProgress();
+ sess.setAttribute(UploadConstant.MONITOR,progress);
+ }
+
+ List monitors = Collections.synchronizedList(new LinkedList());
+ monitors.add(progress);
+ String userStore = LoadFileUtil.getUploadPath(user.getId());
+
+ upload.setStore(UploadConstant.DIR,userStore);
+ upload.setStoreTmpDir(LoadFileUtil.UPLOAD_TEMP_FILES);
+ upload.process(req,monitors,UploadConstant.DEFAULT_ENCODING,UploadConstant.MAX_UPLOADED_FILE_SIZE);
+ upload.store();
+
+ sess.setAttribute(UploadConstant.REPORT,UploadReport.getReport(upload));
+ }
+
+ return new ActionForward(...);;
+ }
+}
+}}}
+
The point of this presentation is not the classes given. The point is that I am would hope that the committers working on the Struts multipart processing would make some attempt to provide a basis for applications other than the Struts upload package. These classes are not meant to be that basis, other than the so-called "Framework Code" given below. If the code given so far is not sufficient to get a response other than the usual indifference, I will just go my own way.
This is about Struts v1.2.6 and forward multipart requests. The first seven classes/interfaces are suggested as a basis for allowing Struts users/developers to implement their own file upload applications. The object of suggesting these classes is to make the use of !ActionForm available to users/developers who want to do something more than the present default file upload application packaged with Struts allows but maintaining backward compatibility.
--------------------------------------------------------------------- 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]