• 大小: 6.29MB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2023-09-25
  • 语言: Java
  • 标签:

资源简介

仿百度网盘、加密、分享、带jar包、带可执行sql,部署既可以运行

资源截图

代码片段和文件信息

package controller;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Message;
import model.MyDiskInfo;
import model.MyFile;
import model.User;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import util.DaoSupport;
import util.DownloadSupport;
import util.FileStorage;
import util.UploadHelper;

import com.alibaba.fastjson.JSON;

import dao.DeleteFileTransaction;
import dao.MessageDao;
import dao.MoveFileTransaction;
import dao.MyDiskInfoDao;
import dao.MyFileDao;
import dao.UploadTransaction;

@Controller
@RequestMapping(“/home“)
public class DiskController extends Support{
private static final String FILEbasePATH = FileStorage.getFilePath();

/**
 * 列出文件夹的内的所有子文件
 * @param id
 * @return
 */
@RequestMapping(“/list_myfile“)
@ResponseBody
public  String listFiles(long idString pwd){
MyFile folder = MyFileDao.getMyFile(id);
List myFiles = null;

if(folder.getIsLock() == 1){
if(folder.getPassword().equals(pwd)){
myFiles = MyFileDao.getFilesByFolderId(id);
}else{
return “fail“;
}
}else{
myFiles = MyFileDao.getFilesByFolderId(id);
}
return JSON.toJSONString(myFiles);
}

/**
 * 上传文件
 * @param request
 * @param folderid
 * @return
 */
@RequestMapping(“/upload/{folderid}“)
@ResponseBody
public String upload(HttpServletRequest request@PathVariable long folderid){
UploadHelper upload = new UploadHelper();
MultipartFile file = upload.getFiles(request).get(0);

String result = “fail“;
String fileName = file.getOriginalFilename();
String suffix = fileName.substring(fileName.lastIndexOf(“.“)+1);

User user = (User) session.getAttribute(“user“);

MyFile myFile = new MyFile();
myFile.setUser_id(user.getId());
myFile.setSize(file.getSize());

if(MyDiskInfoDao.isEnoughSpace(myFile)){
String filePath = FILEbasePATH + new Date().getTime() + “.“ + suffix;

//String filePath = session.getServletContext().getRealPath(“FILE“) +“/“+ new Date().getTime() + “.“ + suffix;
try {
upload.upload(file filePath);//文件没有成功保存返回失败信息

SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd“);

myFile.setCreateDate(sdf.format(new Date()));
myFile.setName(fileName);
myFile.setParent_id(folderid);
myFile.setType(suffix.toLowerCase());
myFile.setPath(MyFileDao.getPath(folderid)+folderid+“/“);
myFile.setLocation(filePath);
myFile.setIsShare(0);
myFile.setDescription(

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2613  2015-10-31 01:55  networkdisk\.classpath

     文件       1044  2013-06-14 17:03  networkdisk\.project

     文件        491  2013-06-14 17:03  networkdisk\.settings\.jsdtscope

     文件         91  2015-11-03 15:21  networkdisk\.settings\org.eclipse.core.resources.prefs

     文件        587  2013-06-14 17:03  networkdisk\.settings\org.eclipse.jdt.core.prefs

     文件        112  2013-06-14 17:03  networkdisk\.settings\org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs

     文件        563  2013-06-14 17:03  networkdisk\.settings\org.eclipse.wst.common.component

     文件        296  2013-06-14 17:03  networkdisk\.settings\org.eclipse.wst.common.project.facet.core.xml

     文件         49  2013-06-14 17:03  networkdisk\.settings\org.eclipse.wst.jsdt.ui.superType.container

     文件          6  2013-06-14 17:03  networkdisk\.settings\org.eclipse.wst.jsdt.ui.superType.name

     文件       9966  2015-11-04 13:37  networkdisk\build\classes\controller\DiskController.class

     文件       1876  2015-11-04 13:37  networkdisk\build\classes\controller\LoginController.class

     文件       2193  2015-11-04 13:37  networkdisk\build\classes\controller\RegisterController.class

     文件       2434  2015-11-04 13:37  networkdisk\build\classes\controller\ShareController.class

     文件        420  2015-11-04 13:37  networkdisk\build\classes\controller\Support.class

     文件       4854  2015-11-04 13:37  networkdisk\build\classes\controller\UserSettingController.class

     文件       3181  2015-11-04 13:37  networkdisk\build\classes\dao\DeleteFileTransaction.class

     文件        819  2015-11-04 13:37  networkdisk\build\classes\dao\MessageDao.class

     文件       2008  2015-11-04 13:37  networkdisk\build\classes\dao\MoveFileTransaction.class

     文件       1336  2015-11-04 13:37  networkdisk\build\classes\dao\MyDiskInfoDao.class

     文件       4319  2015-11-04 13:37  networkdisk\build\classes\dao\MyFileDao.class

     文件        193  2013-06-14 17:03  networkdisk\build\classes\dao\profile.txt

     文件       2646  2015-11-04 13:37  networkdisk\build\classes\dao\RegisterTransaction.class

     文件       2331  2015-11-04 13:37  networkdisk\build\classes\dao\UploadTransaction.class

     文件       3566  2015-11-04 13:37  networkdisk\build\classes\dao\UserDao.class

     文件        102  2015-11-09 14:29  networkdisk\build\classes\database.properties

     文件       1519  2015-11-04 13:37  networkdisk\build\classes\model\Message.class

     文件       1533  2015-11-04 13:37  networkdisk\build\classes\model\MyDiskInfo.class

     文件       3472  2015-11-04 13:37  networkdisk\build\classes\model\MyFile.class

     文件       1721  2015-11-04 13:37  networkdisk\build\classes\model\User.class

............此处省略579个文件信息

评论

共有 条评论

相关资源