作者 lyh

gx

@@ -165,7 +165,7 @@ class ProjectLogic extends BaseLogic @@ -165,7 +165,7 @@ class ProjectLogic extends BaseLogic
165 165
166 public function syncImageFile($location,$project_id){ 166 public function syncImageFile($location,$project_id){
167 if($location == 1){ 167 if($location == 1){
168 - CopyImageFile::dispatch(['project_id'=>$project_id]); 168 +// CopyImageFile::dispatch(['project_id'=>$project_id]);
169 } 169 }
170 return $this->success(); 170 return $this->success();
171 } 171 }
@@ -34,7 +34,6 @@ class CopyImageFileListener implements ShouldQueue @@ -34,7 +34,6 @@ class CopyImageFileListener implements ShouldQueue
34 foreach ($imageList as $k => $v){ 34 foreach ($imageList as $k => $v){
35 $rs = $amazonS3Service->syncImageFiles(getImageUrl($v['path']),$v['size']); 35 $rs = $amazonS3Service->syncImageFiles(getImageUrl($v['path']),$v['size']);
36 $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]); 36 $imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
37 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$rs, true) . PHP_EOL, FILE_APPEND);  
38 } 37 }
39 } 38 }
40 39
@@ -46,7 +45,6 @@ class CopyImageFileListener implements ShouldQueue @@ -46,7 +45,6 @@ class CopyImageFileListener implements ShouldQueue
46 foreach ($fileList as $k => $v){ 45 foreach ($fileList as $k => $v){
47 $amazonS3Service->syncImageFiles(getImageUrl($v['path']),$v['size']); 46 $amazonS3Service->syncImageFiles(getImageUrl($v['path']),$v['size']);
48 $fileList->edit(['is_cos'=>0],['id'=>$v['id']]); 47 $fileList->edit(['is_cos'=>0],['id'=>$v['id']]);
49 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('文件:'.$v['id'], true) . PHP_EOL, FILE_APPEND);  
50 } 48 }
51 } 49 }
52 return true; 50 return true;
@@ -64,30 +64,15 @@ class AmazonS3Service @@ -64,30 +64,15 @@ class AmazonS3Service
64 * @method :post 64 * @method :post
65 * @time :2024/1/23 9:20 65 * @time :2024/1/23 9:20
66 */ 66 */
67 - public function syncImageFiles($files,$size) 67 + public function syncImageFiles($files)
68 { 68 {
69 $key = str_replace_url($files); 69 $key = str_replace_url($files);
70 // try { 70 // try {
71 - $opts = [  
72 - 'http' => [  
73 - 'method' => 'GET',  
74 - 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'  
75 - ],  
76 - 'ssl' => [  
77 - 'verify_peer' => false,  
78 - 'verify_peer_name' => false  
79 - ]  
80 - ];  
81 - $stream_context = stream_context_create($opts);  
82 - $file_handle = fopen($files, 'rb', null, $stream_context);  
83 - if ($file_handle === false) {  
84 - return '无法打开文件';  
85 - } 71 + $file_content = file_get_contents($files);
86 $result = $this->s3->putObject([ 72 $result = $this->s3->putObject([
87 'Bucket' => $this->bucket, 73 'Bucket' => $this->bucket,
88 'Key' => $key, 74 'Key' => $key,
89 - 'Body' => $file_handle,  
90 - 'ContentLength' => $size 75 + 'Body' => $file_content,
91 ]); 76 ]);
92 return $result['ObjectURL']; 77 return $result['ObjectURL'];
93 // } catch (AwsException $e) { 78 // } catch (AwsException $e) {