作者 lyh

gx

@@ -80,18 +80,20 @@ class AmazonS3Service @@ -80,18 +80,20 @@ 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, true) . PHP_EOL, FILE_APPEND);
83 if ($file_handle === false) { 84 if ($file_handle === false) {
  85 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export(2222222, true) . PHP_EOL, FILE_APPEND);
84 return '无法打开文件'; 86 return '无法打开文件';
85 } 87 }
86 $file_stats = fstat($file_handle); 88 $file_stats = fstat($file_handle);
87 $content_length = $file_stats['size']; 89 $content_length = $file_stats['size'];
  90 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($content_length, true) . PHP_EOL, FILE_APPEND);
88 $result = $this->s3->putObject([ 91 $result = $this->s3->putObject([
89 'Bucket' => $this->bucket, 92 'Bucket' => $this->bucket,
90 'Key' => $key, 93 'Key' => $key,
91 'Body' => $file_handle, 94 'Body' => $file_handle,
92 'ContentLength' => $content_length 95 'ContentLength' => $content_length
93 ]); 96 ]);
94 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($result, true) . PHP_EOL, FILE_APPEND);  
95 return $result['ObjectURL']; 97 return $result['ObjectURL'];
96 } catch (AwsException $e) { 98 } catch (AwsException $e) {
97 @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$e->getMessage(), true) . PHP_EOL, FILE_APPEND); 99 @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$e->getMessage(), true) . PHP_EOL, FILE_APPEND);