/**
* Uploads a local file
*
* @param string $object object name
* @param string $localFile local file path, like:"example.jpg"
* @param string $bucket bucket name
* @return boolean
* 将本地的图片上传到oos
*/
public function uploadFile($object, $localFile, $bucketName='')
{
$ossClient = $this->getOssClient();
if (!$ossClient ) {
return false;
}
if (!$bucketName) {
$bucketName = $this->bucketName;
}
try {
$uploadResult = $ossClient->uploadFile($bucketName, $object, $localFile);
return $uploadResult;
} catch (OssException $e) {
Yii::$serivce->helper->errors->add($e->getMessage());
return false;
}
}
解决:https://ram.console.aliyun.com/users
添加权限即可:管理对象存储服务(OSS)权限