阿里云OSS存储之SDK的使用
生活随笔
收集整理的這篇文章主要介紹了
阿里云OSS存储之SDK的使用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
實現圖片上傳
在learn-haoke-manage-api-server中實現圖片上傳功能,以供其他服務使用。
導入依賴
<dependency><groupId>com.aliyun.oss</groupId><artifactId>aliyun-sdk-oss</artifactId><version>2.8.3</version> </dependency> <dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.4</version> </dependency> <dependency><groupId>joda-time</groupId><artifactId>joda-time</artifactId><version>2.9.9</version> </dependency>編寫aliyun.properties配置文件
aliyun.endpoint = http://oss-cn-qingdao.aliyuncs.com aliyun.accessKeyId = LTAI4FpcV3oDNnHkwA7JDtMB8 aliyun.accessKeySecret = yJPCA3BwyIJJU65bf4syFbB4kI8rKw8 aliyun.bucketName=learn-haoke aliyun.urlPrefix=http://learn-haoke.oss-cn-qingdao.aliyuncs.com/ package cn.learn.haoke.dubbo.api.config;import com.aliyun.oss.OSSClient; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource;@Configuration @PropertySource("classpath:aliyun.properties") @ConfigurationProperties(prefix = "aliyun") @Data public class AliyunConfig {private String endpoint;private String accessKeyId;private String accessKeySecret;private String bucketName;private String urlPrefix;@Beanpublic OSSClient oSSClient() {return new OSSClient(endpoint, accessKeyId, accessKeySecret);}}?
超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生總結
以上是生活随笔為你收集整理的阿里云OSS存储之SDK的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 图片存储解决方案的分析
- 下一篇: 实现房源列表的Dubbo服务的开发