package com.tnaot.newshandle.base.oss;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.tnaot.newshandle.base.config.OSSConfiguration;
import com.tnaot.newshandle.base.util.SpringUtils;
/**
* Author: hezishan
* Date: 2018/5/2.
* Description: client
**/
public class IAcsClientFactory {
private static IAcsClient acsClient = null;
/**
* IAcsClient
*
* @return
*/
public static IAcsClient getInstance() {
try {
synchronized (IAcsClientFactory.class) {
if (acsClient == null) {
//
OSSConfiguration ossConfiguration = (OSSConfiguration) SpringUtils.getBean("OSSConfiguration");
if (ossConfiguration != null) {
// DefaultAcsClient
DefaultProfile profile = DefaultProfile.getProfile(
ossConfiguration.getMpsRegionId(),
ossConfiguration.getAccessKeyId(),
ossConfiguration.getAccessKeySecret());
acsClient = new DefaultAcsClient(profile);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return acsClient;
}
}