com.poscoict.glueframework.web.control
Class GlueMultipartRequest

java.lang.Object
  extended by com.poscoict.glueframework.web.control.GlueMultipartRequest

public class GlueMultipartRequest
extends Object

GlueMultipartRequest´Â formÀÌ multipart/form-data Àΰæ¿ì »ý¼ºµÈ´Ù.
GlueMultipartRequest¸¦ Default »ý¼ºÀÚ·Î »ý¼ºÇÑ´Ù. ÃÖ´ë Size´Â 100MbyteÀÌ´Ù.

 File Upload Size º¯°æ ¹æ¹ý
 1: glue.properties¿¡ ´ÙÀ½°ú °°ÀÌ ¼±¾ð. ´Ü, Integer.MAX_VALUE °¡ »óÇÑ°ªÀÓ.
        max.upload.file.size=1000000000
        ÀÌ size¸¦ ³ÑÀ¸¸é connection error¸¦ ¹ß»ýÇÏ°Ô µÈ´Ù.
 2: GlueAbstractAction, GlueAbstractController À» »ó¼Ó¹Þ¾Æ¼­ ±¸Çö
        reqeust.setAttribute(GlueWebConstants.MAXUPLOADSIZE,"1000000000");
        
        ÀÌ GlueMultipartRequest´Â Glue F/W¿¡¼­ »ý¼º ÇÏ¿© ÁÖ¸ç 
        WebÀÌ ¾Æ´Ñ Non Web ÇÁ·Î±×·¥¿¡¼­´Â »ç¿ëÇÒ ¼ö ¾ø´Ù. 
        »ç¿ë ¹æ¹ýÀº ´ÙÀ½°ú °°´Ù.
        GlueMultipartRequest mReq = ctx.getMultiPartRequest();
        if(mReq != null) { 
            File f = getFile("a.txt");
        }
 
 ´ë¿ë·® File Upload Àû¿ë ¹æ¹ý
 ´ë¿ë·® FileÀÇ °æ¿ì WASÀÇ Memory Size¿¡ Á¦¾àÀ» ¹Þ´Â´Ù. 
 ¿¹¸¦ µé¾î WASÀÇ Memory¸¦ 100MB·Î ÇÏ¿´´Ù°í ÇÑ´Ù¸é
 100MB º¸´Ù Å« FileÀº Upload¸¦ ÇÏÁö ¸øÇÏ°Ô µÈ´Ù.
 ÀÌ·±°æ¿ì ´ë¿ë·® FileÀ» Àû¿ëÇÏ¿©¾ß ÇÑ´Ù.
 
 ´ë¿ë·® File Àû¿ë ¹æ¹ý:
 - JAVA Option ¼³Á¤ (Çʼö) : "-Dfile.bigsize=true"
 - JAVA Option ¼³Á¤ (¼±ÅÃ) : "-Dtemp.bigfile.path=ÀÓ½ÃÆÄÀÏÀÇ Àý´ë°æ·Î"
 ´ë¿ë·® FileÀ» Àӽà ÆÄÀÏ·Î ¸ÕÀú ÀúÀåÇÏ¿© »ç¿ëÇÏ°Ô µÈ´Ù.
 µ¿ÀÏ ÆÄÀÏ¸í¿¡ ´ëÇؼ­ Àӽà ÆÄÀÏÀº overwrite µÈ´Ù (since ver.4.2.9)  
 
 Á¦¾à »çÇ×:
 - ±âÁ¸ byte [] ÇüÅ·ΠFileÀÇ Contents¸¦ ¹Þ¾Æ ó¸® ÇÏ´ø LogicÀº ´õÀÌ»ó »ç¿ë µÉ ¼ö ¾ø´Ù.
 - ÇØ´ç Method List :
 public byte[] getFileContent(String fileName)
 public byte[] getFileContentByInputName(String inputName)
 public byte[][] getMultiFilesContentByInputName(String inputName)
 public String toStringFileContent(String fileName)
 


Constructor Summary
GlueMultipartRequest(ServletRequest request)
          »ý¼ºÀÚ(constructor).
 
Method Summary
static void copyFile(File input, File output)
          File À» Copy ÇÑ´Ù.
 Object getFileContentsForHuge(String fileName)
          HTTP Request Stream¿¡¼­ ÀÐ¾î µéÀÎ ÆÄÀÏÀÇ ÄÁÅÙÃ÷¸¦ Return ÇÑ´Ù.
 Iterator<String> getFileNames()
          File ¸íÀ» Ž»öÇϱâ À§ÇÑ Iterator¸¦ ¹Ý³³ÇÑ´Ù.
 InputStream getInputStream(String fileName)
          ¸Þ¸ð¸®¿¡ ij½¬ÇÏ°í ÀÖ´Â ÆÄÀÏÀÇ ³»¿ëÀ» InputStreamÇüÅ·Π¹ÝȯÇÑ´Ù.
 Map<String,String[]> getParameterMap()
           
 File saveFile(String fileName)
          ÆÄÀÏÀ» Server»óÀÇ ÁöÁ¤µÈ ¾÷·Îµå µð·ºÅ丮¿¡ ÀúÀåÇÑ´Ù.
 void setTargetDirectory(String path)
          UploadµÈ FileµéÀ» ÀúÀåÇÏ±æ ¿øÇÒ¶§ »ç¿ëÇÑ´Ù.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlueMultipartRequest

public GlueMultipartRequest(ServletRequest request)
                     throws Exception
»ý¼ºÀÚ(constructor). Internal Use Only. GlueMultipartRequest¸¦ Default »ý¼ºÀÚ·Î »ý¼ºÇÑ´Ù. ÃÖ´ë Size´Â 100MbyteÀÌ´Ù. ¸¸ÀÏ ÀÌ ÀÌ»óÀÇ File Size¸¦ Upload ÇØ¾ß ÇÑ´Ù¸é GlueAbstractActionÀ» »ó¼Ó¹Þ¾Æ¼­ beforeExecute()¿¡¼­ ´ÙÀ½°ú °°ÀÌ ±¸Çö ÇÏ¿©¾ß ÇÑ´Ù.(´ÜÀ§´Â byte)
 ¹æ¹ý 1: glue.properties¿¡ ´ÙÀ½°ú °°ÀÌ ¼±¾ð
        max.upload.file.size=1000000000
 ¹æ¹ý 2: ´ÙÀ½°ú °°ÀÌ ±¸Çö
        reqeust.setAttribute(GlueWebConstants.MAXUPLOADSIZE,"1000000000");
 

Parameters:
request - HTTP Request
Throws:
Exception - Request¸¦ parsing ÇÏ´Â µµÁß ¿¡·¯°¡ ¹ß»ýµÇ¸é throw µÈ´Ù.
Method Detail

setTargetDirectory

public void setTargetDirectory(String path)
UploadµÈ FileµéÀ» ÀúÀåÇÏ±æ ¿øÇÒ¶§ »ç¿ëÇÑ´Ù.
¸¸ÀÏ FileÀ» ÀúÀå ÇÒ °ÍÀ̶ó¸é ¹Ýµå½Ã ÀÌ Method¸¦ È£ÃâÇÏ¿©¾ß ÇÑ´Ù.
»ç¿ë ¹æ¹ýÀº ´ÙÀ½°ú °°´Ù.
  ±âº»ÀûÀ¸·Î Web ȯ°æ¿¡¼­ ´ÙÀ½ 2°³ Action Class°¡ »ç¿ëµÈ´Ù¸é setTargetDirectory()°¡ ½ÇÇàµÈ´Ù. 
 mReq.setTargetDirectory("/upload/chain/");
 mReq.saveFile("a.txt"); 
  
 À§ ¿¹¿¡¼­ ¸¸ÀÏ mReq.setTargetDirectory()¸¦ ¸ÕÀú ½ÇÇàÇÏÁö ¾Ê¾Ò´Ù¸é Error°¡ ¹ß»ýµÈ´Ù.
 

Parameters:
path - String FileÀ» ÀúÀåÇÒ Directory ¸í
Throws:
IllegalArgumentException - DirectoryÀÇ ±ÇÇÑ ¹× À߸øµÈ °æ·Î

getParameterMap

public Map<String,String[]> getParameterMap()

getFileNames

public Iterator<String> getFileNames()
File ¸íÀ» Ž»öÇϱâ À§ÇÑ Iterator¸¦ ¹Ý³³ÇÑ´Ù.

Returns:
Iterator

getInputStream

public InputStream getInputStream(String fileName)
¸Þ¸ð¸®¿¡ ij½¬ÇÏ°í ÀÖ´Â ÆÄÀÏÀÇ ³»¿ëÀ» InputStreamÇüÅ·Π¹ÝȯÇÑ´Ù.

Parameters:
fileName - ÆÄÀϸí
Returns:
ÆÄÀÏ ³»¿ëÀÇ InputStreamÇü °³Ã¼

getFileContentsForHuge

public Object getFileContentsForHuge(String fileName)
HTTP Request Stream¿¡¼­ ÀÐ¾î µéÀÎ ÆÄÀÏÀÇ ÄÁÅÙÃ÷¸¦ Return ÇÑ´Ù. FileÀÇ Contents´Â ´ë¿ë·® File ¿É¼ÇÀ» Àû¿ëÇÑ °æ¿ì¿¡´Â FileÀ» returnÇÏ°í ±×·¸Áö ¾ÊÀº °æ¿ì¿¡´Â byte []¸¦ return ÇÑ´Ù

Parameters:
fileName - ÆÄÀϸí
Returns:
file Contents
Throws:
Exception

copyFile

public static void copyFile(File input,
                            File output)
File À» Copy ÇÑ´Ù.

Parameters:
input - file
output - file

saveFile

public File saveFile(String fileName)
ÆÄÀÏÀ» Server»óÀÇ ÁöÁ¤µÈ ¾÷·Îµå µð·ºÅ丮¿¡ ÀúÀåÇÑ´Ù.

Parameters:
fileName - ÀúÀåÇÏ°íÀÚ ÇÏ´Â ÆÄÀϸí
Returns:
ÀúÀåµÈ ÆÄÀÏÀÇ java.io.File °´Ã¼
Throws:
Exception - FileNotFoundException ÆĶó¹ÌÅÍ·Î ³Ñ¾î¿Â ÆÄÀϸíÀÌ Á¸ÀçÇÏÁö ¾ÊÀ»¶§ ¹ß»ýµÈ´Ù. Exception ÆÄÀÏ ÀúÀåÁß ¿À·ù°¡ ³µÀ»¶§ ¹ß»ýµÈ´Ù.


Copyright © 2013–2017 POSCO ICT. All rights reserved.