Commit f1439d38 authored by christ's avatar christ

SecretKeys

parent 307981a0
...@@ -3,6 +3,7 @@ namespace OSS; ...@@ -3,6 +3,7 @@ namespace OSS;
use OSS\OssClient; use OSS\OssClient;
use OSS\Core\OssException; use OSS\Core\OssException;
use Our\SecretKeys;
/** /**
...@@ -17,13 +18,21 @@ class Common ...@@ -17,13 +18,21 @@ class Common
const accessKeySecret = \Our\SecretKeys::ossAccessKey; const accessKeySecret = \Our\SecretKeys::ossAccessKey;
const bucket = \Our\SecretKeys::ossBucket; const bucket = \Our\SecretKeys::ossBucket;
/**
* Get an OSSClient instance according to config. const endpointPre=SecretKeys::ossEndpointPre;
* const buketPre=SecretKeys::ossBucket;
* @return OssClient An OssClient instance
*/ public static function getOssClientOnline(){
public static function getOssClient() try {
{ $ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpointPre, false);
} catch (OssException $e) {
printf(__FUNCTION__ . "creating OssClient instance: FAILED\n");
printf($e->getMessage() . "\n");
return null;
}
return $ossClient;
}
public static function getOssClientPre(){
try { try {
$ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false); $ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false);
} catch (OssException $e) { } catch (OssException $e) {
...@@ -33,10 +42,30 @@ class Common ...@@ -33,10 +42,30 @@ class Common
} }
return $ossClient; return $ossClient;
} }
/**
* Get an OSSClient instance according to config.
*
* @return OssClient An OssClient instance
*/
public static function getOssClient()
{
if(APP_ENV=='product' || APP_ENV=='productOne'){
return self::getOssClientOnline();
}else{
return self::getOssClientPre();
}
}
public static function getBucketName() public static function getBucketName()
{ {
if(APP_ENV=='product' || APP_ENV=='productOne'){
return self::bucket; return self::bucket;
}else{
return self::buketPre;
}
} }
/** /**
......
...@@ -25,6 +25,11 @@ class SecretKeys { ...@@ -25,6 +25,11 @@ class SecretKeys {
const ossBucket = 'qmoss-01';//存储空间名称 const ossBucket = 'qmoss-01';//存储空间名称
const ossDomain = 'http://qmoss-01.oss-cn-hangzhou.aliyuncs.com';//访问oss使用域名 const ossDomain = 'http://qmoss-01.oss-cn-hangzhou.aliyuncs.com';//访问oss使用域名
//pre环境使用的oss
const ossEndpointPre = 'http://oss-cn-shanghai.aliyuncs.com';//地域节点
const ossBucketPre = 'qmoss-shanghai';//存储空间名称
const ossDomainPre = 'http://qmoss-shanghai.oss-cn-shanghai.aliyuncs.com';//访问oss使用域名
//短信验证码相关 //短信验证码相关
const aliYunSmsAppId = 'LTAICEp88gU0DNMe'; const aliYunSmsAppId = 'LTAICEp88gU0DNMe';
......
...@@ -55,7 +55,7 @@ config.url.convert=/usr/local/bin/wkhtmltoimage ...@@ -55,7 +55,7 @@ config.url.convert=/usr/local/bin/wkhtmltoimage
config.url.resourcesHost = "http://apitest.shenbd.com" config.url.resourcesHost = "http://apitest.shenbd.com"
; 用户中心host ; 用户中心host
config.url.userHost = "" config.url.userHost = ""
config.url.ossHost = "http://testadmin.shenbd.com/data/upload" config.url.ossHost = "https://imgpre.shenbd.com"
; oss 域名 ; oss 域名
;config.url.ossHost = "https://qmoss-01.oss-cn-hangzhou.aliyuncs.com" ;config.url.ossHost = "https://qmoss-01.oss-cn-hangzhou.aliyuncs.com"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment