作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -66,8 +66,8 @@ class AmazonS3Service @@ -66,8 +66,8 @@ class AmazonS3Service
66 */ 66 */
67 public function syncImageFiles($files) 67 public function syncImageFiles($files)
68 { 68 {
69 - $file_link = $this->fetchRemoteImage($files);  
70 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$file_link, true) . PHP_EOL, FILE_APPEND); 69 + $location = '/tmp'.str_replace_url($files);
  70 + $file_link = $this->fetchRemoteImage($files,$location);
71 $key = str_replace_url($files); 71 $key = str_replace_url($files);
72 try { 72 try {
73 $context = stream_context_create([ 73 $context = stream_context_create([
@@ -82,6 +82,7 @@ class AmazonS3Service @@ -82,6 +82,7 @@ class AmazonS3Service
82 'Key' => ltrim($key,'/'), 82 'Key' => ltrim($key,'/'),
83 'Body' => $file_content, 83 'Body' => $file_content,
84 ]); 84 ]);
  85 + unlink($location);
85 return $result['ObjectURL']; 86 return $result['ObjectURL'];
86 } catch (AwsException $e) { 87 } catch (AwsException $e) {
87 return '上传文件到S3时发生错误:' . $e->getMessage(); 88 return '上传文件到S3时发生错误:' . $e->getMessage();
@@ -95,7 +96,7 @@ class AmazonS3Service @@ -95,7 +96,7 @@ class AmazonS3Service
95 * @method :post 96 * @method :post
96 * @time :2024/1/26 12:48 97 * @time :2024/1/26 12:48
97 */ 98 */
98 - public function fetchRemoteImage($url, $localPath = '/tmp/file.jpg') { 99 + public function fetchRemoteImage($url, $localPath) {
99 // 创建 cURL 句柄 100 // 创建 cURL 句柄
100 $curl = curl_init(); 101 $curl = curl_init();
101 // 设置 cURL 选项 102 // 设置 cURL 选项