Solon

aliyun-oss-solon-cloud-plugin

<dependency>
    <groupId>org.noear</groupId>
    <artifactId>aliyun-oss-solon-cloud-plugin</artifactId>
</dependency>

1、描述

分布式扩展插件。基于 aliyun oss 适配的 solon cloud 插件。提供文件存储服务。

2、配置示例

solon.cloud.aliyun.oss.file:
    bucket: world-data-dev
    endpoint: oss-cn-xxx.aliyuncs.com
    accessKey: iWeU7cOoPLRokg2Hdat0jGQC
    secretKey: ZZIH6mT4VLAy68mVP80F7LiB5SpSEM7N

3、应用示例

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();
    }
}

4、代码演示

https://gitee.com/noear/solon-examples/tree/main/9.Solon-Cloud/demo9041-file_aliyun_oss