File Upload
你好,我用过struts2
with commons-fileuplod
。
编辑:当我运行我的演示eclipse with right click and run on server
时,上传文件的时间非常小
**Run From ECLIPSE :**
File Size : 247 MB
Time TAken By upload using Run On server From eclipse :--> 2989 MS
在我deploy same demo war file to Tomcat in webapps folder
和跑步的另一边。所以上传文件比以前的情况需要更多的时间。(为什么会有这么大的时差?)
**Run Using Deploy Demo In Tomcat :**
File Size : 247 MB
Time TAken By upload By deploed war file to tomcat web apps folder :--> 14162 MS
我有java.io.tmpdir
变化MonitoredMultiPartRequest.java
:
System.setProperty("java.io.tmpdir", "D:\\ankit");
System.out.println("java.io.tmpdir :--> " + System.getProperty("java.io.tmpdir"));
UploadListener listener = new UploadListener(servletRequest);
// Create a factory for disk-based file items
FileItemFactory factory = new MonitoredDiskFileItemFactory(listener);
// Create a new file upload handler
ServletFileUpload upload = new ServletFileUpload(factory);
try{
long start = System.currentTimeMillis();
List items = upload.parseRequest(servletRequest);
long end = System.currentTimeMillis();
System.out.println("Time TAken By upload 3.2.1 :--> " + (end - start));
getsystemDetail();
} catch (Exception e){
errors.add(e.getMessage());
}
这里我提到了我的日志:
从 ECLIPSE 运行:
==== System Property =========
java.io.tmpdir :--> D:\ankit
================================
Time TAken By upload File :--> 2989
==================================
##### Heap utilization statistics [MB] #####
Used Memory:46
Free Memory:85
Total Memory:132
Max Memory:675
File system root: C:\
Total space (mb): 79899
Free space (mb): 31833
Usable space (mb): 31833
File system root: D:\
Total space (mb): 158472
Free space (mb): 117366
Usable space (mb): 117366
This is ServletContext RealPath path ::--> D:\eclipseWorkSpace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\FILEUPLOAD_DEMO_OldLIB\
File Uploaded Succ. TO ::-> D:\ankit\eclipse.zip
在 Tomcat 中使用 Deploy Demo 运行:
==== System Property =========
java.io.tmpdir :--> D:\ankit
================================
Time TAken By upload File :--> 14162
==================================
##### Heap utilization statistics [MB] #####
Used Memory:100
Free Memory:31
Total Memory:132
Max Memory:1820
File system root: C:\
Total space (mb): 79899
Free space (mb): 31830
Usable space (mb): 31830
File system root: D:\
Total space (mb): 158472
Free space (mb): 117358
Usable space (mb): 117358
This is ServletContext RealPath path ::--> D:\tools\tomcat7-6\webapps\FILEUPLOAD_DEMO_OldLIB\
File Uploaded Succ. TO ::-> D:\ankit\eclipse.zip