作者 lyh

gx

@@ -40,20 +40,21 @@ class AmazonS3Service @@ -40,20 +40,21 @@ class AmazonS3Service
40 * @method :post 40 * @method :post
41 * @time :2024/1/23 9:20 41 * @time :2024/1/23 9:20
42 */ 42 */
43 - public function uploadFiles(&$files, $s3Key,$filename ) 43 + public function uploadFiles(&$files, $s3Key,$filename)
44 { 44 {
45 $key = $s3Key.'/'.$filename; 45 $key = $s3Key.'/'.$filename;
46 - $Body = fopen($files->getRealPath(), 'r');  
47 - try {  
48 - $result = $this->s3->putObject([  
49 - 'Bucket' => $this->bucket,  
50 - 'Key' => $key,  
51 - 'SourceFile' => $Body,  
52 - 'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改  
53 - ]);  
54 - return $result['ObjectURL'];  
55 - } catch (S3Exception $e) {  
56 - return false;  
57 - } 46 + $body = fopen($files->getRealPath(), 'r');
  47 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export($body, true) . PHP_EOL, FILE_APPEND);
  48 +// try {
  49 +// $result = $this->s3->putObject([
  50 +// 'Bucket' => $this->bucket,
  51 +// 'Key' => $key,
  52 +// 'SourceFile' => $Body,
  53 +// 'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改
  54 +// ]);
  55 +// return $result['ObjectURL'];
  56 +// } catch (S3Exception $e) {
  57 +// return false;
  58 +// }
58 } 59 }
59 } 60 }