From 223f641939ff0f1bd48780e7877f1a81676e8677 Mon Sep 17 00:00:00 2001 From: Frederic Debuire Date: Fri, 14 Dec 2007 14:56:17 +0000 Subject: [PATCH] --- .../org/yacos/web/utils/FileUploadAction.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 YACOSWeb/src/org/yacos/web/utils/FileUploadAction.java diff --git a/YACOSWeb/src/org/yacos/web/utils/FileUploadAction.java b/YACOSWeb/src/org/yacos/web/utils/FileUploadAction.java new file mode 100644 index 0000000..e103696 --- /dev/null +++ b/YACOSWeb/src/org/yacos/web/utils/FileUploadAction.java @@ -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(); + } + } +}