Commit f1439d38 authored by christ's avatar christ

SecretKeys

parent 307981a0
......@@ -3,6 +3,7 @@ namespace OSS;
use OSS\OssClient;
use OSS\Core\OssException;
use Our\SecretKeys;
/**
......@@ -17,13 +18,21 @@ class Common
const accessKeySecret = \Our\SecretKeys::ossAccessKey;
const bucket = \Our\SecretKeys::ossBucket;
/**
* Get an OSSClient instance according to config.
*
* @return OssClient An OssClient instance
*/
public static function getOssClient()
{
const endpointPre=SecretKeys::ossEndpointPre;
const buketPre=SecretKeys::ossBucket;
public static function getOssClientOnline(){
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 {
$ossClient = new OssClient(self::accessKeyId, self::accessKeySecret, self::endpoint, false);
} catch (OssException $e) {
......@@ -33,10 +42,30 @@ class Common
}
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()
{
return self::bucket;
if(APP_ENV=='product' || APP_ENV=='productOne'){
return self::bucket;
}else{
return self::buketPre;
}
}
/**
......
......@@ -25,6 +25,11 @@ class SecretKeys {
const ossBucket = 'qmoss-01';//存储空间名称
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';
......
......@@ -55,7 +55,7 @@ config.url.convert=/usr/local/bin/wkhtmltoimage
config.url.resourcesHost = "http://apitest.shenbd.com"
; 用户中心host
config.url.userHost = ""
config.url.ossHost = "http://testadmin.shenbd.com/data/upload"
config.url.ossHost = "https://imgpre.shenbd.com"
; oss 域名
;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