正在显示
1 个修改的文件
包含
4 行增加
和
7 行删除
| @@ -197,14 +197,11 @@ class ImageController extends Controller | @@ -197,14 +197,11 @@ class ImageController extends Controller | ||
| 197 | if($image_hash !== false){ | 197 | if($image_hash !== false){ |
| 198 | return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'], $name)); | 198 | return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'], $name)); |
| 199 | } | 199 | } |
| 200 | - //保存路径 | ||
| 201 | - $url = $this->config['root'].$this->path; | ||
| 202 | $image_type = $files->getClientOriginalExtension(); | 200 | $image_type = $files->getClientOriginalExtension(); |
| 203 | if(strlen($image_type) > 7){ | 201 | if(strlen($image_type) > 7){ |
| 204 | $this->response('不支持当前格式',Code::SYSTEM_ERROR); | 202 | $this->response('不支持当前格式',Code::SYSTEM_ERROR); |
| 205 | } | 203 | } |
| 206 | $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); | 204 | $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); |
| 207 | - | ||
| 208 | //上传到cos | 205 | //上传到cos |
| 209 | if($this->upload_location == 0){ | 206 | if($this->upload_location == 0){ |
| 210 | $cosService = new CosService(); | 207 | $cosService = new CosService(); |
| @@ -321,9 +318,9 @@ class ImageController extends Controller | @@ -321,9 +318,9 @@ class ImageController extends Controller | ||
| 321 | private function multi(&$files) { | 318 | private function multi(&$files) { |
| 322 | $data = []; | 319 | $data = []; |
| 323 | foreach ($files as $file) { | 320 | foreach ($files as $file) { |
| 324 | - $imageModel = new ImageModel(); | ||
| 325 | $hash = hash_file('sha256', $file->getPathname()); | 321 | $hash = hash_file('sha256', $file->getPathname()); |
| 326 | $name = $file->getClientOriginalName(); | 322 | $name = $file->getClientOriginalName(); |
| 323 | + $imageModel = new ImageModel(); | ||
| 327 | //查看图片是否已上传 | 324 | //查看图片是否已上传 |
| 328 | $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)]; | 325 | $param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)]; |
| 329 | if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){ | 326 | if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){ |
| @@ -336,6 +333,7 @@ class ImageController extends Controller | @@ -336,6 +333,7 @@ class ImageController extends Controller | ||
| 336 | } | 333 | } |
| 337 | $image_type = $file->getClientOriginalExtension(); | 334 | $image_type = $file->getClientOriginalExtension(); |
| 338 | $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); | 335 | $fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0); |
| 336 | + $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); | ||
| 339 | //同步数据到cos | 337 | //同步数据到cos |
| 340 | if($this->upload_location == 0){ | 338 | if($this->upload_location == 0){ |
| 341 | $cosService = new CosService(); | 339 | $cosService = new CosService(); |
| @@ -345,12 +343,11 @@ class ImageController extends Controller | @@ -345,12 +343,11 @@ class ImageController extends Controller | ||
| 345 | $amazonS3Service = new AmazonS3Service(); | 343 | $amazonS3Service = new AmazonS3Service(); |
| 346 | $amazonS3Service->uploadFiles($file,$this->path,$fileName); | 344 | $amazonS3Service->uploadFiles($file,$this->path,$fileName); |
| 347 | } | 345 | } |
| 348 | - //批量存储 | ||
| 349 | - $this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name); | ||
| 350 | $this->synchronizationImage($fileName,$this->upload_location); | 346 | $this->synchronizationImage($fileName,$this->upload_location); |
| 351 | $data[] = $this->responseData($this->path.'/'.$fileName,$name); | 347 | $data[] = $this->responseData($this->path.'/'.$fileName,$name); |
| 348 | + $hash = $name = ''; | ||
| 352 | } | 349 | } |
| 353 | - $this->response('图片资源',Code::SUCCESS,$data); | 350 | + $this->response('图片资源',Code::SUCCESS,$data); |
| 354 | } | 351 | } |
| 355 | 352 | ||
| 356 | /** | 353 | /** |
-
请 注册 或 登录 后发表评论