
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
Linux (KUbuntu 5.10) running Orion 2.0.5 application server
|
|
|
Multipart requests, using either the fileUpload interceptor or MultiPartRequestWrapper, are not cleaned up correctly.
Markup:
<form action="/command/Thumbnails/create" method="POST" enctype="multipart/form-data">
<input type='file' name='newThumbnail' />
<input type='text' name='newThumbnailCaption' />
<input type='submit' value='Upload' />
</form>
Behaviour:
When this form is submitted with the fileUpload interceptor in place, two temporary files are created named upload_00000000.tmp and upload_00000001.tmp. One of the temporary files contains the image, the other temporary file contains the contents of the text field. Upon completion of the action, only the file containing the image is deleted - the other file is left in the temporary directory indefinitely. This behaviour is identical when the lower-level MultiPartRequestWrapper is used explicitly, as in the second example below.
Example 1 with the fileUpload interceptor:
import java.io.File;
public class ThumbnailsView {
private File newThumbnail;
private String newThumbnailContentType;
private String newThumbnailFileName;
private String newThumbnailCaption;
public String create() { return "success"; }
public void setNewThumbnail(File newThumbnail) { this.newThumbnail = newThumbnail; }
public void setNewThumbnailContentType(String newThumbnailContentType) {
this.newThumbnailContentType = newThumbnailContentType;
}
public void setNewThumbnailFileName(String newThumbnailFileName) {
this.newThumbnailFileName = newThumbnailFileName;
}
public void setNewThumbnailCaption(String newThumbnailCaption) {
this.newThumbnailCaption = newThumbnailCaption;
}
}
Example 2 using MultiPartRequestWrapper:
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.webwork.dispatcher.multipart.MultiPartRequestWrapper;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
public class ThumbnailsView implements ServletRequestAware {
private HttpServletRequest request;
private File newThumbnail;
private String newThumbnailContentType;
private String newThumbnailFileName;
private String newThumbnailCaption;
public String create() {
MultiPartRequestWrapper wrapper = (MultiPartRequestWrapper) request;
try {
newThumbnail = wrapper.getFiles("newThumbnail")[0];
newThumbnailContentType = wrapper.getContentTypes("newThumbnail")[0];
newThumbnailFileName = wrapper.getFileSystemNames("newThumbnail")[0];
} finally {
newThumbnail.delete();
}
return "success";
}
public void setServletRequest(HttpServletRequest request) {
this.request = request;
}
public void setNewThumbnailCaption(String newThumbnailCaption) {
this.newThumbnailCaption = newThumbnailCaption;
}
}
|
|
Description
|
Multipart requests, using either the fileUpload interceptor or MultiPartRequestWrapper, are not cleaned up correctly.
Markup:
<form action="/command/Thumbnails/create" method="POST" enctype="multipart/form-data">
<input type='file' name='newThumbnail' />
<input type='text' name='newThumbnailCaption' />
<input type='submit' value='Upload' />
</form>
Behaviour:
When this form is submitted with the fileUpload interceptor in place, two temporary files are created named upload_00000000.tmp and upload_00000001.tmp. One of the temporary files contains the image, the other temporary file contains the contents of the text field. Upon completion of the action, only the file containing the image is deleted - the other file is left in the temporary directory indefinitely. This behaviour is identical when the lower-level MultiPartRequestWrapper is used explicitly, as in the second example below.
Example 1 with the fileUpload interceptor:
import java.io.File;
public class ThumbnailsView {
private File newThumbnail;
private String newThumbnailContentType;
private String newThumbnailFileName;
private String newThumbnailCaption;
public String create() { return "success"; }
public void setNewThumbnail(File newThumbnail) { this.newThumbnail = newThumbnail; }
public void setNewThumbnailContentType(String newThumbnailContentType) {
this.newThumbnailContentType = newThumbnailContentType;
}
public void setNewThumbnailFileName(String newThumbnailFileName) {
this.newThumbnailFileName = newThumbnailFileName;
}
public void setNewThumbnailCaption(String newThumbnailCaption) {
this.newThumbnailCaption = newThumbnailCaption;
}
}
Example 2 using MultiPartRequestWrapper:
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.webwork.dispatcher.multipart.MultiPartRequestWrapper;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
public class ThumbnailsView implements ServletRequestAware {
private HttpServletRequest request;
private File newThumbnail;
private String newThumbnailContentType;
private String newThumbnailFileName;
private String newThumbnailCaption;
public String create() {
MultiPartRequestWrapper wrapper = (MultiPartRequestWrapper) request;
try {
newThumbnail = wrapper.getFiles("newThumbnail")[0];
newThumbnailContentType = wrapper.getContentTypes("newThumbnail")[0];
newThumbnailFileName = wrapper.getFileSystemNames("newThumbnail")[0];
} finally {
newThumbnail.delete();
}
return "success";
}
public void setServletRequest(HttpServletRequest request) {
this.request = request;
}
public void setNewThumbnailCaption(String newThumbnailCaption) {
this.newThumbnailCaption = newThumbnailCaption;
}
}
|
Show » |
|