作者 lyh

gx

... ... @@ -197,14 +197,11 @@ class ImageController extends Controller
if($image_hash !== false){
return $this->response('图片资源',Code::SUCCESS,$this->responseData($image_hash['path'], $name));
}
//保存路径
$url = $this->config['root'].$this->path;
$image_type = $files->getClientOriginalExtension();
if(strlen($image_type) > 7){
$this->response('不支持当前格式',Code::SYSTEM_ERROR);
}
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
//上传到cos
if($this->upload_location == 0){
$cosService = new CosService();
... ... @@ -321,9 +318,9 @@ class ImageController extends Controller
private function multi(&$files) {
$data = [];
foreach ($files as $file) {
$imageModel = new ImageModel();
$hash = hash_file('sha256', $file->getPathname());
$name = $file->getClientOriginalName();
$imageModel = new ImageModel();
//查看图片是否已上传
$param = ['hash'=>$hash,'refer'=>$this->param['refer'] ?? 0,'is_cos'=>(($this->upload_location == 0) ? 1 : 0)];
if(isset($this->cache['project_id']) && !empty($this->cache['project_id'])){
... ... @@ -336,6 +333,7 @@ class ImageController extends Controller
}
$image_type = $file->getClientOriginalExtension();
$fileName = $this->getOnlyFilename($name,$param['project_id'] ?? 0);
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
//同步数据到cos
if($this->upload_location == 0){
$cosService = new CosService();
... ... @@ -345,12 +343,11 @@ class ImageController extends Controller
$amazonS3Service = new AmazonS3Service();
$amazonS3Service->uploadFiles($file,$this->path,$fileName);
}
//批量存储
$this->saveMysql($imageModel,$file->getSize(),$image_type,$fileName,$hash,$this->upload_location,$file->getMimeType(),$name);
$this->synchronizationImage($fileName,$this->upload_location);
$data[] = $this->responseData($this->path.'/'.$fileName,$name);
$hash = $name = '';
}
$this->response('图片资源',Code::SUCCESS,$data);
$this->response('图片资源',Code::SUCCESS,$data);
}
/**
... ...