Commit dffa08df authored by Liu lu's avatar Liu lu

使用oss固定目录

parent 69b68780
......@@ -179,18 +179,21 @@ class UploadOssService
* 上传本地文件到oss
* @param string $localFilePath
* @param string $ossFilePath 枚举key
* @param bool $fixedDir 使用oss固定目录
* @return mixed
* @throws HttpResponseException
* @author Liu lu
* date 2023-02-09
*/
public function uploadLocalFile(string $localFilePath, string $ossFilePath)
public function uploadLocalFile(string $localFilePath, string $ossFilePath,$fixedDir=false)
{
$extension = pathinfo(parse_url($localFilePath,PHP_URL_PATH),PATHINFO_EXTENSION);
// $ossFilePath = 'oss2/'.env('APP_ENV').'/'.env('APP_NAME') ."/{$ossFilePath}/". md5($localFilePath).'.'.$extension;
if($fixedDir){
$ossFilePath = 'oss2/'.env('APP_ENV').'/'.env('APP_NAME') ."/{$ossFilePath}/". md5($localFilePath).'.'.$extension;
}else{
$fileName = $this->genUniqueFileName() . '.' . $extension;
$ossFilePath = 'oss2/'. $this->appDev .'/'. $this->appName ."/{$ossFilePath}/". today() .'/'. $fileName;
}
try {
$oss = $this->factory->get('oss');
......
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