use of com.lmxdawn.other.res.HuaWeiObsPostParamRes in project exchange by lmxdawn.
the class HuaWeiObsServiceImpl method createUploadPostParam.
@Override
public HuaWeiObsPostParamRes createUploadPostParam(String suffix) {
StorageSettingVo storageSettingVo = settingService.listToStorageSettingVo();
if (storageSettingVo == null) {
return null;
}
String accessKey = storageSettingVo.getAccessKey();
String secretKey = storageSettingVo.getSecretKey();
String endPoint = storageSettingVo.getUploadUrl();
String bucketName = storageSettingVo.getBucket();
String objectKey = UUIDStringUtils.randomUUID() + "." + suffix;
// URL有效期,3600秒
long expireSeconds = 3600L;
ObsConfiguration config = new ObsConfiguration();
config.setEndPoint(endPoint);
config.setAuthType(AuthTypeEnum.OBS);
ObsClient obsClient = new ObsClient(accessKey, secretKey, config);
Map<String, Object> formParams = new HashMap<>();
String xObsAcl = "public-read";
PostSignatureRequest request = new PostSignatureRequest();
request.setExpires(expireSeconds);
formParams.put("x-obs-acl", xObsAcl);
request.setFormParams(formParams);
PostSignatureResponse response = obsClient.createPostSignature(request);
HuaWeiObsPostParamRes huaWeiObsPostParamRes = new HuaWeiObsPostParamRes();
huaWeiObsPostParamRes.setKey(objectKey);
huaWeiObsPostParamRes.setXObsAcl(xObsAcl);
huaWeiObsPostParamRes.setAccessKeyId(accessKey);
huaWeiObsPostParamRes.setPolicy(response.getPolicy());
huaWeiObsPostParamRes.setSignature(response.getSignature());
String postUrl = "https://" + bucketName + "." + endPoint;
huaWeiObsPostParamRes.setUrl(postUrl);
return huaWeiObsPostParamRes;
}
use of com.lmxdawn.other.res.HuaWeiObsPostParamRes in project exchange by lmxdawn.
the class HuaWeiObsServiceImpl method createUploadPostParamAll.
@Override
public List<HuaWeiObsPostParamRes> createUploadPostParamAll(List<String> suffixs) {
StorageSettingVo storageSettingVo = settingService.listToStorageSettingVo();
if (storageSettingVo == null) {
return null;
}
String accessKey = storageSettingVo.getAccessKey();
String secretKey = storageSettingVo.getSecretKey();
String endPoint = storageSettingVo.getUploadUrl();
String bucketName = storageSettingVo.getBucket();
// URL有效期,3600秒
long expireSeconds = 3600L;
ObsConfiguration config = new ObsConfiguration();
config.setEndPoint(endPoint);
config.setAuthType(AuthTypeEnum.OBS);
ObsClient obsClient = new ObsClient(accessKey, secretKey, config);
Map<String, Object> formParams = new HashMap<>();
String xObsAcl = "public-read";
formParams.put("x-obs-acl", xObsAcl);
List<HuaWeiObsPostParamRes> list = new ArrayList<>();
for (String suffix : suffixs) {
String objectKey = UUIDStringUtils.randomUUID() + "." + suffix;
PostSignatureRequest request = new PostSignatureRequest();
request.setExpires(expireSeconds);
request.setFormParams(formParams);
PostSignatureResponse response = obsClient.createPostSignature(request);
HuaWeiObsPostParamRes huaWeiObsPostParamRes = new HuaWeiObsPostParamRes();
huaWeiObsPostParamRes.setKey(objectKey);
huaWeiObsPostParamRes.setXObsAcl(xObsAcl);
huaWeiObsPostParamRes.setAccessKeyId(accessKey);
huaWeiObsPostParamRes.setPolicy(response.getPolicy());
huaWeiObsPostParamRes.setSignature(response.getSignature());
String postUrl = "https://" + bucketName + "." + endPoint;
huaWeiObsPostParamRes.setUrl(postUrl);
list.add(huaWeiObsPostParamRes);
}
return list;
}
Aggregations