作者 lyh

gx

@@ -67,7 +67,7 @@ class AmazonS3Service @@ -67,7 +67,7 @@ class AmazonS3Service
67 public function syncImageFiles($files) 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 = [ 71 $opts = [
72 'http' => [ 72 'http' => [
73 'method' => 'GET', 73 'method' => 'GET',
@@ -80,14 +80,11 @@ class AmazonS3Service @@ -80,14 +80,11 @@ class AmazonS3Service
80 ]; 80 ];
81 $stream_context = stream_context_create($opts); 81 $stream_context = stream_context_create($opts);
82 $file_handle = fopen($files, 'rb', null, $stream_context); 82 $file_handle = fopen($files, 'rb', null, $stream_context);
83 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($file_handle.'1111111111', true) . PHP_EOL, FILE_APPEND);  
84 if ($file_handle === false) { 83 if ($file_handle === false) {
85 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export(2222222, true) . PHP_EOL, FILE_APPEND);  
86 return '无法打开文件'; 84 return '无法打开文件';
87 } 85 }
88 $file_stats = fstat($file_handle); 86 $file_stats = fstat($file_handle);
89 $content_length = $file_stats['size']; 87 $content_length = $file_stats['size'];
90 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($content_length, true) . PHP_EOL, FILE_APPEND);  
91 $result = $this->s3->putObject([ 88 $result = $this->s3->putObject([
92 'Bucket' => $this->bucket, 89 'Bucket' => $this->bucket,
93 'Key' => $key, 90 'Key' => $key,
@@ -95,9 +92,8 @@ class AmazonS3Service @@ -95,9 +92,8 @@ class AmazonS3Service
95 'ContentLength' => $content_length 92 'ContentLength' => $content_length
96 ]); 93 ]);
97 return $result['ObjectURL']; 94 return $result['ObjectURL'];
98 - } catch (AwsException $e) {  
99 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$e->getMessage(), true) . PHP_EOL, FILE_APPEND);  
100 - return '上传文件到S3时发生错误:' . $e->getMessage();  
101 - } 95 +// } catch (AwsException $e) {
  96 +// return '上传文件到S3时发生错误:' . $e->getMessage();
  97 +// }
102 } 98 }
103 } 99 }