*/
package mir.session;
-import java.io.InputStream;
-
import org.apache.commons.fileupload.FileItem;
+import java.io.File;
+import java.io.InputStream;
+import java.io.IOException;
+
public class CommonsUploadedFileAdapter implements UploadedFile {
private FileItem fileItem;
fileItem = aFileItem;
}
- public InputStream getInputStream() throws SessionExc, SessionFailure{
+ public void writeToFile(File aFile) throws SessionExc, SessionFailure {
+ try {
+ aFile.getParentFile().mkdirs();
+ fileItem.write(aFile);
+ }
+ catch (Exception e) {
+ throw new SessionFailure(e);
+ }
+ }
+
+ public InputStream getInputStream() throws SessionExc, SessionFailure {
try {
return fileItem.getInputStream();
}
- catch (Throwable t) {
- throw new SessionFailure(t);
+ catch (IOException e) {
+ throw new SessionFailure(e);
}
- };
+ }
public String getFileName() {
return fileItem.getName();