Spring Boot 實戰 打造私人雲盤

2021-09-20 15:30:09 字數 2527 閱讀 1992

前言

最近在做工作流的事情,正好有個需求,要新增乙個附件上傳的功能,曾找過不少上傳外掛程式,都不是特別滿意。無意中發現乙個很好用的開源web檔案管理器外掛程式 elfinder,功能比較完善,社群也很活躍,還方便二次開發。

軟體位址

springboot

elfinder

週末抽時間做了乙個簡單的案例,希望對大家有所幫助,下面是簡單的專案截圖。

專案基於 springboot 註解配置實現,在第三方外掛程式進行二次開發。

# 執行類,內部呼叫,實現前端相關功能

file-manager.command=com.itstyle.cloud.common.elfinder.command

file-manager.thumbnail.width=80

file-manager.volumes[0].node=

file-manager.volumes[0].source=filesystem

file-manager.volumes[0].alias=file

# 檔案存放目錄,可以自定義

file-manager.volumes[0].path=d:/cloudfile

file-manager.volumes[0]._default=true

file-manager.volumes[0].locale=

file-manager.volumes[0].constraint.locked=false

file-manager.volumes[0].constraint.readable=true

file-manager.volumes[0].constraint.writable=true

elfinderconfiguration 讀取配置:

@component

public class elfinderconfiguration

elfinderstoragefactory 初始化 基礎bean:

@configuration

public class elfinderconfig

@bean(name = "elfinderstoragefactory")

public elfinderstoragefactory getelfinderstoragefactory()

@bean(name = "elfinderstorage")

public elfinderstorage getelfinderstorage()

defaultelfinderstorage.setthumbnailwidth(defaultthumbnailwidth);

defaultelfinderstorage.setvolumes(elfindervolumes);

defaultelfinderstorage.setvolumeids(elfindervolumeids);

defaultelfinderstorage.setvolumelocales(elfindervolumelocales);

defaultelfinderstorage.setvolumesecurities(elfindervolumesecurities);

return defaultelfinderstorage;}}

clouddiskcontroller 控制層實現:

}//省略部分**

}最後,前端頁面引入:

總體來說個人使用還是非常不錯的,當然對於一些成熟的網盤系統還是有一些差距。

原始碼:

Spring Boot 實戰 打造自己的雲盤

最近在做工作流的事情,正好有個需求,要新增乙個附件上傳的功能,曾找過不少上傳外掛程式,都不是特別滿意。無意中發現乙個很好用的開源web檔案管理器外掛程式 elfinder,功能比較完善,社群也很活躍,還方便二次開發。軟體位址 springboot elfinder 週末抽時間做了乙個簡單的案例,希望...

Spring Boot功能實戰

新增了spring boot基礎依賴後,如要使用web mvc功能,只需要新增如下啟動器即可,spring boot會自動裝配web功能。org.springframework.bootgroupid spring boot starter webartifactid dependency depe...

Spring Boot整合Shiro實戰

spring boot整合shiro許可權驗證框架,可參考 org.apache.shirogroupid shiro spring boot web starterartifactid 1.4.0version dependency shiroconfig configurationpropert...