Loading src/UploadOss/UploadOssService.php +8 −5 Original line number Original line Diff line number Diff line Loading @@ -179,18 +179,21 @@ class UploadOssService * 上传本地文件到oss * 上传本地文件到oss * @param string $localFilePath * @param string $localFilePath * @param string $ossFilePath 枚举key * @param string $ossFilePath 枚举key * @param bool $fixedDir 使用oss固定目录 * @return mixed * @return mixed * @throws HttpResponseException * @throws HttpResponseException * @author Liu lu * @author Liu lu * date 2023-02-09 * 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); $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; $fileName = $this->genUniqueFileName() . '.' . $extension; $ossFilePath = 'oss2/'. $this->appDev .'/'. $this->appName ."/{$ossFilePath}/". today() .'/'. $fileName; $ossFilePath = 'oss2/'. $this->appDev .'/'. $this->appName ."/{$ossFilePath}/". today() .'/'. $fileName; } try { try { $oss = $this->factory->get('oss'); $oss = $this->factory->get('oss'); Loading Loading
src/UploadOss/UploadOssService.php +8 −5 Original line number Original line Diff line number Diff line Loading @@ -179,18 +179,21 @@ class UploadOssService * 上传本地文件到oss * 上传本地文件到oss * @param string $localFilePath * @param string $localFilePath * @param string $ossFilePath 枚举key * @param string $ossFilePath 枚举key * @param bool $fixedDir 使用oss固定目录 * @return mixed * @return mixed * @throws HttpResponseException * @throws HttpResponseException * @author Liu lu * @author Liu lu * date 2023-02-09 * 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); $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; $fileName = $this->genUniqueFileName() . '.' . $extension; $ossFilePath = 'oss2/'. $this->appDev .'/'. $this->appName ."/{$ossFilePath}/". today() .'/'. $fileName; $ossFilePath = 'oss2/'. $this->appDev .'/'. $this->appName ."/{$ossFilePath}/". today() .'/'. $fileName; } try { try { $oss = $this->factory->get('oss'); $oss = $this->factory->get('oss'); Loading