Merge remote-tracking branch 'origin/cc_20230520_partner'
This commit is contained in:
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhangchenbiao
|
* @author zhangchenbiao
|
||||||
@@ -47,9 +48,9 @@ public class OssClientController {
|
|||||||
public ResponseResult getUploadFileConfig(){
|
public ResponseResult getUploadFileConfig(){
|
||||||
// host的格式为 bucketname.endpoint
|
// host的格式为 bucketname.endpoint
|
||||||
String host = "https://" + bucket + "." + endpoint;
|
String host = "https://" + bucket + "." + endpoint;
|
||||||
|
OSS client = null;
|
||||||
OSS client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
|
||||||
try {
|
try {
|
||||||
|
client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||||
long expireTime = 300;
|
long expireTime = 300;
|
||||||
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
|
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
|
||||||
Date expiration = new Date(expireEndTime);
|
Date expiration = new Date(expireEndTime);
|
||||||
@@ -65,6 +66,10 @@ public class OssClientController {
|
|||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.info("exception", e);
|
log.info("exception", e);
|
||||||
throw new ServiceException(ErrorCodeEnum.GET_INFO_ERROR);
|
throw new ServiceException(ErrorCodeEnum.GET_INFO_ERROR);
|
||||||
|
}finally {
|
||||||
|
if(Objects.nonNull(client)){
|
||||||
|
client.shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhangchenbiao
|
* @author zhangchenbiao
|
||||||
@@ -45,8 +46,9 @@ public class OssClientController {
|
|||||||
// host的格式为 bucketname.endpoint
|
// host的格式为 bucketname.endpoint
|
||||||
String host = "https://" + bucket + "." + endpoint;
|
String host = "https://" + bucket + "." + endpoint;
|
||||||
|
|
||||||
OSS client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
OSS client = null;
|
||||||
try {
|
try {
|
||||||
|
client = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
|
||||||
long expireTime = 300;
|
long expireTime = 300;
|
||||||
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
|
long expireEndTime = System.currentTimeMillis() + expireTime * 1000;
|
||||||
Date expiration = new Date(expireEndTime);
|
Date expiration = new Date(expireEndTime);
|
||||||
@@ -61,6 +63,10 @@ public class OssClientController {
|
|||||||
return ResponseResult.success(result);
|
return ResponseResult.success(result);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.info("exception", e);
|
log.info("exception", e);
|
||||||
|
}finally {
|
||||||
|
if(Objects.nonNull(client)){
|
||||||
|
client.shutdown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ResponseResult.success();
|
return ResponseResult.success();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user