作者 lyh

gx

@@ -66,10 +66,10 @@ class AmazonS3Service @@ -66,10 +66,10 @@ class AmazonS3Service
66 */ 66 */
67 public function syncImageFiles($files) 67 public function syncImageFiles($files)
68 { 68 {
69 - $file_link = $this->fetchRemoteImage($files); 69 + $file_content = curl_c($files);
  70 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($file_content, true) . PHP_EOL, FILE_APPEND);
70 $key = str_replace_url($files); 71 $key = str_replace_url($files);
71 try { 72 try {
72 - $file_content = $file_link;  
73 $result = $this->s3->putObject([ 73 $result = $this->s3->putObject([
74 'Bucket' => $this->bucket, 74 'Bucket' => $this->bucket,
75 'Key' => ltrim($key,'/'), 75 'Key' => ltrim($key,'/'),
@@ -82,34 +82,4 @@ class AmazonS3Service @@ -82,34 +82,4 @@ class AmazonS3Service
82 } 82 }
83 } 83 }
84 84
85 - /**  
86 - * @remark :零时文件  
87 - * @name :fetchRemoteImage  
88 - * @author :lyh  
89 - * @method :post  
90 - * @time :2024/1/26 12:48  
91 - */  
92 - public function fetchRemoteImage($url) {  
93 - // 创建 cURL 句柄  
94 - $curl = curl_init();  
95 - // 设置 cURL 选项  
96 - curl_setopt($curl, CURLOPT_URL, $url);  
97 -// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);  
98 -// curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);  
99 - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);  
100 - // 执行请求并获取内容  
101 - $response = curl_exec($curl);  
102 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($response, true) . PHP_EOL, FILE_APPEND);  
103 - // 检查请求是否成功  
104 - if ($response === false) {  
105 - $error = curl_error($curl);  
106 - // 处理错误  
107 - return 'cURL 错误:' . $error;  
108 - } else {  
109 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($response, true) . PHP_EOL, FILE_APPEND);  
110 - return $response;  
111 - }  
112 - // 关闭 cURL 句柄  
113 - curl_close($curl);  
114 - }  
115 } 85 }