使用OSS的PHP sdk版本,总是报这个错误: InvalidBucketName: The specified bucket is not valid
代码:
配置:
'OSS_AccessKeyId'
=>....
,
'OSS_AccessKeySecret'
=>......
,
'OSS_BjEndpoint'
=>
"http://oss-cn-beijing.aliyuncs.com"
,
代码:
class
OssClientApi {
private static
$_ossClient
=
false
;
private static function
createOssClient(){
if
(
is_object
(
self
::
$_ossClient
) )
return self
::
$_ossClient
;
$accessKeyId
= C(
'OSS_AccessKeyId'
);
$accessKeySecret
= C(
'OSS_AccessKeySecret'
);
$endpoint
= C(
'OSS_BjEndpoint'
);
echo
"endpoint:"
.
$endpoint
.
"
\r\n
"
;
try
{
self
::
$_ossClient
=
new
OssClient(
$accessKeyId
,
$accessKeySecret
,
$endpoint
,
true
);
}
catch
(OssException
$e
) {
addLogError(
"can not creat OssClient. msg:"
.
$e
->getMessage(),
__FUNCTION__
,
__LINE__
);
return false
;
}
return self
::
$_ossClient
;
}
public static function
put(
$bucket
,
$object
,
$content
){
self
::
createOssClient
();
if
(
false
==
self
::
$_ossClient
)
return false
;
try
{
self
::
$_ossClient
->putObject(
$bucket
,
$object
,
$content
);
}
catch
(OssException
$e
) {
addLogError(
"can not put object. msg:"
.
$e
->getMessage(),
__FUNCTION__
,
__LINE__
);
print_r
(
$e
);
return false
;
}
return true
;
}
}
我使用的sdk是2.0.4版本,最新版,Endpoint使用[size=; font-size: 12pt,12pt]
http://oss-cn-beijing.aliyuncs.com
或
oss-cn-beijing.aliyuncs.com都是报这个错误
请大牛们帮忙看看,这到底是神马问题?
-------------------------
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。