This commit is contained in:
20
YACOSWeb/src/org/yacos/web/utils/FileUploadAction.java
Normal file
20
YACOSWeb/src/org/yacos/web/utils/FileUploadAction.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package org.yacos.web.utils;
|
||||
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.webflow.action.AbstractAction;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
|
||||
public class FileUploadAction extends AbstractAction {
|
||||
|
||||
protected Event doExecute(RequestContext context) throws Exception {
|
||||
MultipartFile file = context.getRequestParameters().getRequiredMultipartFile("file");
|
||||
if (file.getSize() > 0) {
|
||||
// data was uploaded
|
||||
context.getFlashScope().put("file", new String(file.getBytes()));
|
||||
return success();
|
||||
} else {
|
||||
return error();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user