EOS Low-Code Platform 8 EOS Low-Code Platform 8
  • 8.3.2 (opens new window)
  • 8.3.1 (opens new window)
  • 8.3LA1 (opens new window)
  • 8.2GA (opens new window)
产品简介
学习指南
更新说明
安装与集成
初见EOS
低代码开发手册
专业代码开发手册
专题场景实战
公共服务框架
应用运行治理
升级手册
常见问题
  • 附件存储集成
  • 功能说明
  • 数据库存储
  • 本地存储
  • 阿里OSS存储
  • Nexus存储
  • HDFS存储
  • 扩展说明

# 附件存储集成

# 功能说明

平台提供了附件存储能力,主要为低开的附件上传控件提供服务,将附件上传到不同的基础设施上。平台默认提供了本地路径存储、OSS存储、Nexus存储、HDFS存储等常用模式,也支持用户自行扩展其他存储实现。平台默认提供的附件存储模式所涉及到的配置,都在application-afc.properties文件中。

# 数据库存储

afc.attachments.persistence-mode=db

数据库模式平台内置了附件表,不需要额外的配置。

# 本地存储

afc.attachments.persistence-mode=local
afc.attachments.local.dir=

afc.attachments.local.dir需要配置磁盘上的绝对路径,如果没有配置,默认附件会存储到应用外置工作目录下的attachments目录中。

# 阿里OSS存储

afc.attachments.persistence-mode=aliyun-oss
afc.attachments.aliyun-oss.endpoint=
afc.attachments.aliyun-oss.access-key-id=
afc.attachments.aliyun-oss.access-key-secret=
afc.attachments.aliyun-oss.bucket-name=

对于endpoint、access-key-id、access-key-secret、bucket-name的具体含义,可自行查看阿里云OSS的SDK文档,具体参考链接:https://help.aliyun.com/zh/oss/product-overview/what-is-oss (opens new window)

# Nexus存储

afc.attachments.persistence-mode=nexus
afc.attachments.nexus.repository-url=
afc.attachments.nexus.username=
afc.attachments.nexus.password=

一般使用nexus存储的时候,在nexus上建立的是raw类型的仓库。

# HDFS存储

afc.attachments.persistence-mode=hdfs
afc.attachments.hdfs.root.user=
afc.attachments.hdfs.defaultFS=
afc.attachments.hdfs.defaultPrincipal=
afc.attachments.hdfs.defaultKrb5conf=
afc.attachments.hdfs.defaultKeytab=
afc.attachments.hdfs.upload.path=

当HDFS存储需要使用kerberos认证时,需要配置defaultPrincipal、defaultKrb5conf、defaultKeytab属性,具体含义可参考HDFS的kerberos认证介绍。

# 扩展说明

如果用户提供了其他类型的存储,用于管理附件,则需要基于AFCenter的SDK进行扩展,具体扩展方式如下:

平台提供的是com.primeton.ext.system.utility.ServiceExtensionLoader进行扩展,类似JDK的ServiceLoader机制,在jar包的META-INF/services目录下新建service文件,文件名为:com.primeton.gocom.afcenter.common.service.IFileStorePersistence,文件内容参考

com.primeton.gocom.afcenter.common.service.impl.LocalFileStorePersistence;StoreType=local;instanceMode=spring;

上述配置内容基于分号分割成三段,第一段是存储实现类,第二段为存储类型(最终需要在application-afc.properties文件中进行配置,将afc.attachments.persistence-mode的值设置为该存储类型),第三段目前没有其他作用,固定配置即可。

实现类需继承com.primeton.gocom.afcenter.common.service.impl.AbstractFileStorePersistence类,重点实现如下方法:

public class Test extends AbstractFileStorePersistence{

    //根据文件存储类型,生成文件存储地址,通常类似磁盘、对象存储这些需要实现,对于数据库之类则不需要
    @Override
    protected String generateFileUrl(FileStore fileStore) throws Exception {
        return null;
    }

    //获取附件流
    @Override
    protected void doGetFileStoreInputStream(FileStore fileStore, File localPersistenceFile) throws Exception {

    }

    //保存附件内容
    @Override
    protected void doSaveFileStoreContent(FileStore fileStore, InputStream inputContent) throws Exception {

    }

    //删除附件内容
    @Override
    protected void doRemoveFileStoreContent(FileStore fileStore) throws Exception {

    }

    //创建统一的目录,有些存储必须现有目录才能继续上传文件,大部分场景不需要关注
    @Override
    protected void doCreateDirectoryContent(FileStore fileStore) throws Exception {

    }
}

← 消息通道集成 第一个表单 →