作者 lyh

gx

@@ -155,7 +155,7 @@ class ImageController extends Controller @@ -155,7 +155,7 @@ class ImageController extends Controller
155 //同步数据到cos 155 //同步数据到cos
156 if($this->upload_location == 1){ 156 if($this->upload_location == 1){
157 $cosService = new CosService(); 157 $cosService = new CosService();
158 - $cosService->uploadFile($this->path,$fileName); 158 + $cosService->uploadFile($files,$this->path,$fileName);
159 }else{ 159 }else{
160 $res = $files->move($url,$fileName); 160 $res = $files->move($url,$fileName);
161 if ($res === false) { 161 if ($res === false) {
@@ -20,7 +20,7 @@ class CosService @@ -20,7 +20,7 @@ class CosService
20 * @method :post 20 * @method :post
21 * @time :2023/7/19 15:28 21 * @time :2023/7/19 15:28
22 */ 22 */
23 - public function uploadFile($path,$filename) 23 + public function uploadFile(&$files,$path,$filename)
24 { 24 {
25 $cos = config('filesystems.disks.cos'); 25 $cos = config('filesystems.disks.cos');
26 $cosClient = new Client([ 26 $cosClient = new Client([
@@ -34,7 +34,7 @@ class CosService @@ -34,7 +34,7 @@ class CosService
34 $cosClient->putObject([ 34 $cosClient->putObject([
35 'Bucket' => $cos['bucket'], 35 'Bucket' => $cos['bucket'],
36 'Key' => $key, 36 'Key' => $key,
37 - 'Body' => fopen(config('filesystems.disks.upload')['root'].$path.'/'.$filename, 'r'), 37 + 'Body' => fopen($files->getRealPath(), 'r'),
38 ]); 38 ]);
39 return $key; 39 return $key;
40 } 40 }