新增阿里云oss上传文件

This commit is contained in:
2023-03-02 16:51:47 +08:00
parent d51d5355a0
commit 186f92c4ea
11 changed files with 188 additions and 159 deletions
+20
View File
@@ -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());
}
}
}