基于javaweb的网盘系统设计和实现(java+ssm+jpa)
很多同学都有自己的网盘,方便存储一些java学习教程。该毕业设计实现了一个简易的网盘,包含文件上传和文件分享等功能。
后端技术采用了spring,spring mvc,JPA,前端采用了thymeleaf模板语言。整体业务功能相对不是太复杂,亮点是文件分享功能。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
List<FileMsg> fileMsgList = fileService.search(key, userName, path);
// 判断文件转码情况
for (FileMsg fileMsg : fileMsgList) {
// 跳过文件夹
if (fileMsg.getSize().equals("Directory")) {
continue;
}
// 正常文件
int suffixidx = (int) StringUtil.getfilesuffix(fileMsg.getName(), true);
String suffix = fileMsg.getName().substring(suffixidx);
if (suffix.equals("mkv") || suffix.equals("rmvb") || suffix.equals("avi") || suffix.equals("wmv")
|| suffix.equals("3gp") || suffix.equals("rm")) {
// 取非文件夹的所有文件名
List<String> namelist = fileMsgList.stream()
.filter(f -> !f.getSize().equals("Directory"))
.map(FileMsg::getName)
.collect(Collectors.toList());
// 含有转码文件的情况下
if (namelist.contains(fileMsg.getName().substring(0, suffixidx) + "mp4")) {
Map<String, Object> map = FfmpegUtil.ffmpegTaskMap.get(fileMsg.getLink());
}
// 文件上传
@RequestMapping(value = "/upload", produces = "application/json; charset=utf-8")
@ResponseBody
public ResponseMsg upload(@RequestParam MultipartFile file, String path, HttpServletRequest request) {
if (path == null) {
path = "/";
}
ResponseMsg j = new ResponseMsg();
if (file.isEmpty()) {
j.setMsg("请选择要上传的文件!");
return j;
}
// 获取用户名
String userName = WebUtil.getUserNameByRequest(request);
// 上传文件
boolean b = fileService.upload(file, userName, path);
// 反馈用户信息
String downloadLink = "";
Map<Object, String> map = new HashMap<>();
if (!link.isEmpty()) {
// downloadLink= fileService.fileShareCodeDecode(link);
downloadLink = link;
}
//在数据库查找这个链接
LinkSecret linkSecret = linkSecretService.findLinkSecretBysecretLink(downloadLink);
String secret1 = linkSecret.getSecret();
if (secret1.toLowerCase().equals(secret.toLowerCase())) {
linkSecretService.addOneToDownloadNum(linkSecret);
logger.warn("密码正确!");
logger.warn("codeArray[1]路径:" + link);
ResponseMsg responseMsg = new ResponseMsg();
private LinkSecretServiceImpl linkSecretService;
@Autowired
private FileServiceImpl fileService;
private SaveServiceImpl saveService;
/**
* 安卓上查看分享记录的接口
*
* @return
*/
@RequestMapping(value = "/shareRecord", produces = "application/json; charset=utf-8")
@ResponseBody
public List<ShareMessage> shareRecord(HttpServletRequest request) {
User user = (User) request.getSession().getAttribute("user");
String userName = user.getUserName();
List<ShareMessage> shareMessageList = new ArrayList<>();
@Value("${tempPath}")
public void setTempPath(String tempPath) {
FileController.tempPath = tempPath;
}
@Value("${fileRootPath}")
public void setFileRootPath(String fileRootPath) <