Solon

aws-s3-solon-cloud-plugin

v2.7.5 </> markdown
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>aws-s3-solon-cloud-plugin</artifactId>
</dependency>

1、描述

分布式扩展插件。基于 aws s3 适配的 solon cloud 插件。提供所有 's3' 协议文件存储服务。但,只支持配置一个供应商。

2、云端能力接口

接口说明备注
CloudFileService云端文件服务

3、配置示例

solon.cloud.aws.s3.file:
    bucket: world-data-dev
    regionId: ap-xxx-1
    accessKey: iWeU7cOoPLR****
    secretKey: ZZIH6mT4VLAy68mVP8****

或者

solon.cloud.aws.s3.file:
    bucket: world-data-dev
    endpoint: obs.cn-southwest-2.myhuaweicloud.com
    accessKey: iWeU7cOoPLR****
    secretKey: ZZIH6mT4VLAy68mVP8****

其它 s3 bucket 可选属性配置

demo1_bucket:
  pathStyleAccessEnabled: false #minio 一般要设为 true
  chunkedEncodingDisabled: false #一般要设为 true
  accelerateModeEnabled: false
  payloadSigningEnabled: false
  dualstackEnabled: false
  forceGlobalBucketAccessEnabled: false
  useArnRegionEnabled: false
  regionalUsEast1EndpointEnabled: false

4、应用示例

public class DemoApp {
    public void main(String[] args) {
        SolonApp app = Solon.start(DemoApp.class, args);

        String key = "test/" + Utils.guid();
        String val = "Hello world!";
        
        //上传媒体
        Result rst = CloudClient.file().put(key, new Media(val));
        
        //获取媒体,并转为字符串
        String val2 = CloudClient.file().get(key).bodyAsString();
    }
}

5、代码演示

https://gitee.com/noear/solon-examples/tree/main/9.Solon-Cloud/demo9042-file_aws_s3