<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ page import="com.gagaframework.web.util.GagaFileUtil" %>
<%@ page import="com.oreilly.servlet.MultipartRequest" %>
<%@ page import="com.oreilly.servlet.multipart.DefaultFileRenamePolicy" %>

<%
    String contentType = request.getContentType();
    if (contentType == null || !contentType.startsWith("multipart/form-data")) {
        return;
    }

    String serverType = System.getProperty("spring.profiles.active");
    String seUploadPath = "";
    String seViewUrl = "";

    if (serverType.equals("locd") || serverType.equals("locp")) {
        seUploadPath = "/WIDE/workspace/files/data/smartEditor";
        seViewUrl = "//ldimage.pastelmall.com";
    } else if (serverType.equals("dev")) {
        seUploadPath = "/data/files/smartEditor";
        seViewUrl = "//" + serverType + ".image.pastelmall.com";
    } else if (serverType.equals("qas") || serverType.equals("run")) {
        seUploadPath = "/data/files/smartEditor";
        seViewUrl = "//image.pastelmall.com";
    }

    System.out.println("seUploadPath: " + seUploadPath);
    System.out.println("seViewUrl: " + seViewUrl);

    MultipartRequest multipartRequest = new MultipartRequest(request
            , seUploadPath
            , 50000000
            , "utf-8"
            , new DefaultFileRenamePolicy()
    );

    String objImage = GagaFileUtil.getConcatenationPath(seViewUrl, "smartEditor", multipartRequest.getFilesystemName("Filedata"));
    System.out.println("objImage: " + objImage);

    out.clear();
%>FILENM:<%=objImage%>
