新增阿里云oss上传文件
This commit is contained in:
@@ -79,4 +79,24 @@ class Oss
|
||||
{
|
||||
return str_replace('+00:00', '.000Z', gmdate('c', $time));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传
|
||||
* @param string $filename 图片名称
|
||||
* @param mixed $content 内容 字符串或文件流
|
||||
* @return string
|
||||
*/
|
||||
public function putObject(string $filename, mixed $content): string
|
||||
{
|
||||
try {
|
||||
$ossClient = $this->createClient();
|
||||
|
||||
$object = "applet/doctor/card/".$filename;
|
||||
$ossClient->putObject($this->config['bucket'], $object, $content);
|
||||
|
||||
return $object;
|
||||
}catch(\Exception $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user