资源简介
完整的java大文件分块上传支持断点续传,包含jar包,可以直接导入eclipse使用。
代码片段和文件信息
package com.airodlcx;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
//import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FileUtils;
/**
* Servlet implementation class UploadVideo
*/
public class CheckChumServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public CheckChumServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
// TODO Auto-generated method stub
response.getWriter().append(“Served at: “).append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request HttpServletResponse response)
throws ServletException IOException {
String fileName = request.getParameter(“fileName“);
String fileMd5 = request.getParameter(“fileMd5“);
String chunk = request.getParameter(“chunk“);
String chunkSize = request.getParameter(“chunkSize“);
String guid = request.getParameter(“guid“);
String path = request.getSession().getServletContext().getRealPath(“/upload“);
File checkFile = new File(path+“/“+guid+“/“+chunk);
response.setContentType(“text/html;charset=utf-8“);
//检查文件是否存在,且大小是否一致
if(checkFile.exists() && checkFile.length()==Integer.parseInt(chunkSize)){
//上传过
try {
response.getWriter().write(“{\“ifExist\“:1}“);
} catch (IOException e) {
e.printStackTrace();
}
}else{
//没有上传过
try {
response.getWriter().write(“{\“ifExist\“:0}“);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2447 2017-09-28 18:08 upload\.classpath
文件 906 2017-09-28 18:08 upload\.project
文件 567 2017-09-28 18:08 upload\.settings\.jsdtscope
文件 57 2017-09-28 18:08 upload\.settings\org.eclipse.core.resources.prefs
文件 670 2017-09-28 18:08 upload\.settings\org.eclipse.jdt.core.prefs
文件 470 2017-09-28 18:08 upload\.settings\org.eclipse.wst.common.component
文件 305 2017-09-28 18:08 upload\.settings\org.eclipse.wst.common.project.facet.core.xm
文件 49 2017-09-28 18:08 upload\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2017-09-28 18:08 upload\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 2550 2017-09-28 18:08 upload\build\classes\com\airodlcx\CheckChumServlet.class
文件 1862 2017-09-28 18:08 upload\build\classes\com\airodlcx\ChunkInformModel.class
文件 3782 2017-09-28 18:08 upload\build\classes\com\airodlcx\CustomMultipartResolver.class
文件 1379 2017-09-28 18:08 upload\build\classes\com\airodlcx\FileUploadMessageModel.class
文件 1584 2017-09-28 18:08 upload\build\classes\com\airodlcx\FileUploadProgressListener.class
文件 1425 2017-09-28 18:08 upload\build\classes\com\airodlcx\UploadController.class
文件 3084 2017-09-28 18:08 upload\build\classes\com\airodlcx\UploadSuccessServlet.class
文件 4780 2017-09-28 18:08 upload\build\classes\com\airodlcx\UploadVideoServlet.class
文件 1918 2017-09-28 18:08 upload\build\classes\resources\viewSpace.xm
文件 2901 2017-09-28 18:08 upload\src\com\airodlcx\CheckChumServlet.java
文件 1155 2017-09-28 18:08 upload\src\com\airodlcx\ChunkInformModel.java
文件 2386 2017-09-28 18:08 upload\src\com\airodlcx\CustomMultipartResolver.java
文件 1111 2017-09-28 18:08 upload\src\com\airodlcx\FileUploadMessageModel.java
文件 913 2017-09-28 18:08 upload\src\com\airodlcx\FileUploadProgressListener.java
文件 685 2017-09-28 18:08 upload\src\com\airodlcx\UploadController.java
文件 2479 2017-09-28 18:08 upload\src\com\airodlcx\UploadSuccessServlet.java
文件 4264 2017-09-28 18:08 upload\src\com\airodlcx\UploadVideoServlet.java
文件 1918 2017-09-28 18:08 upload\src\resources\viewSpace.xm
文件 9924 2017-09-28 18:08 upload\WebContent\admin\artdialog\css\ui-dialog.css
文件 10005 2017-09-28 18:08 upload\WebContent\admin\artdialog\dist\dialog-min.js
文件 20999 2017-09-28 18:08 upload\WebContent\admin\assets\bootstrap\css\bootstrap-responsive.css
............此处省略264个文件信息
评论
共有 条评论