Class FsService
java.lang.Object
io.github.xezzon.zeroweb.storage.fs.FsService
- All Implemented Interfaces:
IStorageService
@Service
@ConditionalOnBean(ZerowebFsConfig.class)
public class FsService
extends Object
implements IStorageService
文件系统存储服务实现。
如果没有配置文件系统,则不会注册 Bean。
- Author:
- xezzon
-
Nested Class Summary
Nested classes/interfaces inherited from interface IStorageService
IStorageService.Factory -
Constructor Summary
ConstructorsConstructorDescriptionFsService(ZerowebFsConfig zerowebFsConfig, IAttachmentService attachmentService) 注入依赖 -
Method Summary
Modifier and TypeMethodDescriptionbyte[]download(Attachment attachment) 下载文件getDownloadEndpoint(Attachment attachment) 获取附件下载地址getUploadAddress(Attachment attachment) 获取附件的上传地址getUploadAddress(Attachment attachment, int partNumber) 获取附件分段上传地址getUploadInfo(Attachment attachment) 获取上传元数据provider()申明附件的存储类型voidupload(Attachment attachment, byte[] fileContent) 上传文件
-
Constructor Details
-
FsService
注入依赖- Parameters:
zerowebFsConfig- 文件系统配置attachmentService- 附件管理服务
-
-
Method Details
-
provider
Description copied from interface:IStorageService申明附件的存储类型- Specified by:
providerin interfaceIStorageService- Returns:
FileProviderEnum存储类型枚举
-
getUploadInfo
Description copied from interface:IStorageService获取上传元数据
为给定的附件生成并返回上传所需的元数据信息。
- Specified by:
getUploadInfoin interfaceIStorageService- Parameters:
attachment-Attachment附件对象,包含文件相关信息- Returns:
UploadInfo上传元数据对象
-
getUploadAddress
Description copied from interface:IStorageService获取附件的上传地址
为给定的附件生成一个用于直接上传文件的地址。
- Specified by:
getUploadAddressin interfaceIStorageService- Parameters:
attachment-Attachment附件对象,包含文件相关信息- Returns:
UploadEndpoint上传地址对象
-
getUploadAddress
Description copied from interface:IStorageService获取附件分段上传地址
为给定附件的特定分段生成上传地址。 此方法适用于需要分段上传大文件的情况。
- Specified by:
getUploadAddressin interfaceIStorageService- Parameters:
attachment-Attachment附件对象,包含文件相关信息partNumber- 文件分段的序号- Returns:
UploadEndpoint分段上传地址对象
-
getDownloadEndpoint
Description copied from interface:IStorageService获取附件下载地址
为给定的附件生成一个用于下载文件的地址。
- Specified by:
getDownloadEndpointin interfaceIStorageService- Parameters:
attachment-Attachment附件信息对象- Returns:
DownloadEndpoint下载地址对象
-
upload
Description copied from interface:IStorageService上传文件
将文件内容上传到存储服务。
- Specified by:
uploadin interfaceIStorageService- Parameters:
attachment-Attachment附件对象,包含文件相关信息fileContent- 文件内容的字节数组
-
download
Description copied from interface:IStorageService下载文件
从存储服务下载指定附件的内容。
- Specified by:
downloadin interfaceIStorageService- Parameters:
attachment-Attachment附件对象,包含文件相关信息- Returns:
- 文件内容的字节数组
-