JAVA開発メモ
FileUpload のバックアップ差分(No.2)
 

[トップ|一覧|単語検索|最終更新|バックアップ|ヘルプ]



  *Jakarta Commons FileUpload





  


   boolean isMultipart = FileUpload.isMultipartContent(request);
  

   DiskFileUpload upload = new DiskFileUpload();
  

   upload.setSizeThreshold(yourMaxMemorySize);
   upload.setSizeMax(yourMaxRequestSize);
   upload.setRepositoryPath(yourTempDirectory);
  

   List items = upload.parseRequest(request);
  

   Iterator iter = items.iterator();
   while (iter.hasNext()) {
       FileItem item = (FileItem) iter.next();
  
       if (item.isFormField()) {

       } else {

       }
   }
  

   if (!item.isFormField()) {
       String fieldName = item.getFieldName();
       String fileName = item.getName();
       String contentType = item.getContentType();
       boolean isInMemory = item.isInMemory();
       long sizeInBytes = item.getSize();
       ...
   }
  

   if (writeToFile) {
       File uploadedFile = new File(...);
       item.write(uploadedFile);
   } else {
       InputStream uploadedStream = item.getInputStream();
       ...
       uploadedStream.close();
   }
  

   byte[] data = item.get();
   ...
  

トップ 一覧 検索 最終更新 バックアップ   ヘルプ   最終更新のRSS

Modified by MT22(Moriwaki Takashi)

"PukiWiki" 1.3.7 Copyright © 2001,2002,2003 PukiWiki Developers Team. License is GNU/GPL.
Based on "PukiWiki" 1.3 by sng
Powered by PHP 7.4.33

HTML convert time to 0.004 sec.