修改 AliyunOssConfig 访问key、访问secret字段名称,方便和其他几种 文件服务器统一
This commit is contained in:
parent
30558aa7e1
commit
b863b079d9
|
|
@ -20,8 +20,8 @@ public class AliyunOssConfig {
|
|||
/**
|
||||
* aliyun oss相关配置
|
||||
* ACCESS_KEY_SECRET
|
||||
* AccessKeyId eg:LTAI4GFov2QymkmPf9cXdH5z
|
||||
* AccessKeySecret eg:ap8nmIvD1TctcCLsADS4JbkOoXOluW
|
||||
* AccessKeyId 【secretKey】eg:LTAI4GFov2QymkmPf9cXdH5z
|
||||
* AccessKeySecret 【secretKey】 eg:ap8nmIvD1TctcCLsADS4JbkOoXOluW
|
||||
* BucketName eg:yuebaoxiao
|
||||
* Endpoint eg:oss-cn-shenzhen.aliyuncs.com
|
||||
*
|
||||
|
|
@ -29,8 +29,8 @@ public class AliyunOssConfig {
|
|||
*
|
||||
* 具体项目里面必须替换掉
|
||||
*/
|
||||
private String accessKeyId = "";
|
||||
private String accessKeySecret = "";
|
||||
private String accessKey = "";
|
||||
private String secretKey = "";
|
||||
private String bucketName = "";
|
||||
private String endpoint = "";
|
||||
/**
|
||||
|
|
@ -45,20 +45,20 @@ public class AliyunOssConfig {
|
|||
*/
|
||||
private String domain = null;
|
||||
|
||||
public String getAccessKeyId() {
|
||||
return accessKeyId;
|
||||
public String getAccessKey() {
|
||||
return accessKey;
|
||||
}
|
||||
|
||||
public void setAccessKeyId(String accessKeyId) {
|
||||
this.accessKeyId = accessKeyId;
|
||||
public void setAccessKey(String accessKey) {
|
||||
this.accessKey = accessKey;
|
||||
}
|
||||
|
||||
public String getAccessKeySecret() {
|
||||
return accessKeySecret;
|
||||
public String getSecretKey() {
|
||||
return secretKey;
|
||||
}
|
||||
|
||||
public void setAccessKeySecret(String accessKeySecret) {
|
||||
this.accessKeySecret = accessKeySecret;
|
||||
public void setSecretKey(String secretKey) {
|
||||
this.secretKey = secretKey;
|
||||
}
|
||||
|
||||
public String getBucketName() {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
|
@ -112,7 +111,7 @@ public class AliyunOssDsfServiceImpl implements IDfsService {
|
|||
/*
|
||||
* Constructs a client instance with your account for accessing OSS
|
||||
*/
|
||||
OSS client = new OSSClientBuilder().build(aliyunOssConfig.getEndpoint(), aliyunOssConfig.getAccessKeyId(), aliyunOssConfig.getAccessKeySecret());
|
||||
OSS client = new OSSClientBuilder().build(aliyunOssConfig.getEndpoint(), aliyunOssConfig.getAccessKey(), aliyunOssConfig.getSecretKey());
|
||||
String storePath = getStorePath(fileUrl);
|
||||
List<String> keys = new ArrayList<>();
|
||||
keys.add(storePath);
|
||||
|
|
@ -190,7 +189,7 @@ public class AliyunOssDsfServiceImpl implements IDfsService {
|
|||
* demo https://github.com/aliyun/aliyun-oss-java-sdk/blob/master/src/samples/UploadSample.java
|
||||
*/
|
||||
private String ossUploadFileSmall(String endpoint, String picturePath, MultipartFile file) throws IOException {
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, aliyunOssConfig.getAccessKeyId(), aliyunOssConfig.getAccessKeySecret());
|
||||
OSS ossClient = new OSSClientBuilder().build(endpoint, aliyunOssConfig.getAccessKey(), aliyunOssConfig.getSecretKey());
|
||||
try {
|
||||
// 上传文件 (上传文件流的形式)
|
||||
PutObjectResult putResult = ossClient.putObject(aliyunOssConfig.getBucketName(), picturePath, file.getInputStream());
|
||||
|
|
@ -271,7 +270,7 @@ public class AliyunOssDsfServiceImpl implements IDfsService {
|
|||
*/
|
||||
ClientBuilderConfiguration conf = new ClientBuilderConfiguration();
|
||||
conf.setIdleConnectionTime(1000);
|
||||
OSS client = new OSSClientBuilder().build(endpoint, aliyunOssConfig.getAccessKeyId(), aliyunOssConfig.getAccessKeySecret(), conf);
|
||||
OSS client = new OSSClientBuilder().build(endpoint, aliyunOssConfig.getAccessKey(), aliyunOssConfig.getSecretKey(), conf);
|
||||
|
||||
try {
|
||||
/*
|
||||
|
|
@ -485,7 +484,7 @@ public class AliyunOssDsfServiceImpl implements IDfsService {
|
|||
|
||||
@Override
|
||||
public String objectsCapacityStr() {
|
||||
OSS client = new OSSClientBuilder().build(aliyunOssConfig.getEndpoint(), aliyunOssConfig.getAccessKeyId(), aliyunOssConfig.getAccessKeySecret());
|
||||
OSS client = new OSSClientBuilder().build(aliyunOssConfig.getEndpoint(), aliyunOssConfig.getAccessKey(), aliyunOssConfig.getSecretKey());
|
||||
final int maxKeys = 200;
|
||||
String nextMarker = null;
|
||||
ObjectListing objectListing;
|
||||
|
|
@ -545,7 +544,7 @@ public class AliyunOssDsfServiceImpl implements IDfsService {
|
|||
} catch (MalformedURLException e) {
|
||||
// 忽略
|
||||
}
|
||||
OSS ossClient = new OSSClientBuilder().build(aliyunOssConfig.getEndpoint(), aliyunOssConfig.getAccessKeyId(), aliyunOssConfig.getAccessKeySecret());
|
||||
OSS ossClient = new OSSClientBuilder().build(aliyunOssConfig.getEndpoint(), aliyunOssConfig.getAccessKey(), aliyunOssConfig.getSecretKey());
|
||||
// 设置URL过期时间为12小时,最大值就是43200
|
||||
Date expiration = new Date(System.currentTimeMillis() + (43200 * 1000));
|
||||
// 生成以GET方法访问的签名URL,访客可以直接通过浏览器访问相关内容。
|
||||
|
|
|
|||
Loading…
Reference in New Issue