1、pom.xml引入阿里云依赖
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.10.2</version>
</dependency>
2、实现 AttachmentProxy 接口
注意:目前版本不支持路径自定义 所以这里 增加了一层固定跟目录 path
public class AliyunOssProxy implements AttachmentProxy {
/**
* @param inputStream 数据流
* @param path 上传位置
*/
@Override
public void upLoad(InputStream inputStream, String path) {
// yourEndpoint填写Bucket所在地域对应的Endpoint。以华东1(杭州)为例,Endpoint填写为https://oss-cn-hangzhou.aliyuncs.com。
String endpoint = "yourEndpoint";
// 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
String accessKeyId = "yourAccessKeyId";
Stri