类 EngineFileController
java.lang.Object
net.sohelp.boot.admin.core.base.BaseController
net.sohelp.boot.engine.web.controller.EngineFileController
@RestController("engine-web-file")
@ConditionalOnExpression("${sohelp-boot.engine.enabled:true} && ${sohelp-boot.engine.file.enabled:true}")
@RequestMapping("/engine/web/file")
public class EngineFileController
extends BaseController
文件管理
- 从以下版本开始:
- 2023/12/8
- 作者:
- AaronFung
-
字段概要
从类继承的字段 net.sohelp.boot.admin.core.base.BaseController
request, response -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明文件删除接口 根据提供的文件ID和引用ID删除文件,并验证用户操作权限文件下载接口 根据提供的文件ID下载对应文件,如果文件不存在或没有权限则返回失败信息。图片预览接口 根据提供的文件ID和可选的引用ID,预览指定的图片文件。文件预览接口 用于预览指定ID的文件,支持多种文件类型,如PDF等。文件重命名接口 该接口用于对指定文件进行重命名操作文件上传接口 用于上传一个或多个文件,并返回上传文件的ID列表从类继承的方法 net.sohelp.boot.admin.core.base.BaseController
error, error, fail, fail, fail, getLoginID, getLoginName, getLoginOrgID, getLoginOrgName, getLoginUser, getNickname, getTenantId, getUserName, getUserNo, i18n, i18n, isAdministrator, isDeveloper, limit, offset, ok, ok, response, response, responseStream, success, success, success, success, validateToken
-
构造器详细资料
-
EngineFileController
public EngineFileController()
-
-
方法详细资料
-
upload
@PostMapping("/upload") @Permission("") public ApiResult<List<Long>> upload(@RequestParam(required=false) String refid, @RequestParam("files") org.springframework.web.multipart.MultipartFile[] files) throws IOException, BusiException, TokenAuthenticationException, AccessPermissionException, SQLException 文件上传接口 用于上传一个或多个文件,并返回上传文件的ID列表- 参数:
refid- 关联ID,非必需参数,用于验证地址和模块操作权限files- 要上传的文件数组,必需参数- 返回:
- 返回包含上传文件ID的列表
- 抛出:
IOException- 如果文件上传过程中发生I/O错误BusiException- 如果业务逻辑处理中出现异常TokenAuthenticationException- 如果令牌认证失败AccessPermissionException- 如果访问权限验证失败SQLException- 如果数据库操作中出现异常
-
download
@GetMapping("/download") public Object download(@RequestParam(required=false) String refid, @RequestParam("id") String id) throws BusiException, TokenAuthenticationException, AccessPermissionException, SQLException, UnsupportedEncodingException 文件下载接口 根据提供的文件ID下载对应文件,如果文件不存在或没有权限则返回失败信息。- 参数:
refid- 引用ID,用于验证模块操作权限(可选)id- 文件ID,用于从数据库中查询文件信息- 返回:
- 下载成功时返回null,失败时返回错误信息
- 抛出:
BusiException- 业务异常,当业务逻辑出现错误时抛出TokenAuthenticationException- 令牌认证异常,当令牌认证失败时抛出AccessPermissionException- 访问权限异常,当没有访问权限时抛出SQLException- 数据库查询异常,当数据库查询出现错误时抛出UnsupportedEncodingException
-
delete
@PostMapping("/delete") @Permission("") public ApiResult<Object> delete(@RequestBody Map<String, Object> dataMap) throws BusiException, TokenAuthenticationException, AccessPermissionException, SQLException文件删除接口 根据提供的文件ID和引用ID删除文件,并验证用户操作权限- 参数:
dataMap- 包含文件ID和引用ID等信息的Map - id: 文件ID,用于标识需要删除的文件 - refid: 引用ID,用于验证用户对该文件的操作权限- 返回:
- ApiResult
- 抛出:
BusiException- 业务异常,如文件ID为空或删除文件失败时抛出TokenAuthenticationException- 令牌认证异常,如用户未登录或令牌无效时抛出AccessPermissionException- 访问权限异常,如用户无操作权限时抛出SQLException- 数据库异常,如数据库操作失败时抛出
-
rename
@PostMapping("/rename") @Permission("") public ApiResult<Object> rename(@RequestParam(required=false) String refid, @RequestParam("id") String id, @RequestParam("newFileName") String newFileName) throws BusiException, TokenAuthenticationException, AccessPermissionException, SQLException 文件重命名接口 该接口用于对指定文件进行重命名操作- 参数:
refid- 可选参数,关联的文件引用IDid- 文件的唯一标识符IDnewFileName- 新的文件名- 返回:
- 返回操作结果的ApiResult对象
- 抛出:
BusiException- 业务逻辑异常TokenAuthenticationException- 令牌认证异常AccessPermissionException- 访问权限异常SQLException- 数据库操作异常
-
preview
@GetMapping("/preview") public Object preview(@RequestParam(required=false) String refid, @RequestParam("id") String id) throws BusiException, TokenAuthenticationException, AccessPermissionException, SQLException, IOException 文件预览接口 用于预览指定ID的文件,支持多种文件类型,如PDF等。通过文件ID获取文件信息,并验证文件存在后,将文件内容以流的形式返回给客户端。- 参数:
refid- 引用ID,用于验证地址和模块操作权限(可选)id- 文件ID,用于从数据库中查询文件信息- 返回:
- 如果文件存在且验证通过,则返回文件内容流;否则返回错误信息。
- 抛出:
BusiException- 业务异常,如文件不存在或数据库查询错误TokenAuthenticationException- 令牌认证异常,如未通过身份验证AccessPermissionException- 访问权限异常,如无权限访问该文件SQLException- 数据库查询异常IOException- 文件IO异常,如文件读取错误
-
image
@GetMapping("/image") public Object image(@RequestParam(required=false) String refid, @RequestParam("id") String id, @RequestParam(value="fileType",required=false) String fileType) throws BusiException, TokenAuthenticationException, AccessPermissionException, SQLException, IOException 图片预览接口 根据提供的文件ID和可选的引用ID,预览指定的图片文件。如果文件不存在或无法访问,将返回错误信息。- 参数:
refid- 引用ID,用于验证地址和模块操作权限,可选参数id- 文件ID,用于从数据库中查询文件信息fileType- 文件类型,可选参数,当前接口中未直接使用,但可用于扩展- 返回:
- 不直接返回对象,而是通过响应流输出图片数据
- 抛出:
BusiException- 业务异常,如文件查询失败等TokenAuthenticationException- 令牌认证异常,如用户未登录或令牌无效AccessPermissionException- 访问权限异常,如用户无文件查看权限SQLException- 数据库查询异常IOException- 文件读写异常
-