正在显示
1 个修改的文件
包含
5 行增加
和
5 行删除
| @@ -69,7 +69,7 @@ class AmazonS3Service | @@ -69,7 +69,7 @@ class AmazonS3Service | ||
| 69 | $file_link = $this->fetchRemoteImage($files); | 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); | 70 | @file_put_contents(storage_path('logs/lyh_error.log'), var_export('图片:'.$file_link, true) . PHP_EOL, FILE_APPEND); |
| 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([ |
| 74 | 'ssl' => [ | 74 | 'ssl' => [ |
| 75 | 'verify_peer' => false, | 75 | 'verify_peer' => false, |
| @@ -79,13 +79,13 @@ class AmazonS3Service | @@ -79,13 +79,13 @@ class AmazonS3Service | ||
| 79 | $file_content = file_get_contents($file_link, false, $context); | 79 | $file_content = file_get_contents($file_link, false, $context); |
| 80 | $result = $this->s3->putObject([ | 80 | $result = $this->s3->putObject([ |
| 81 | 'Bucket' => $this->bucket, | 81 | 'Bucket' => $this->bucket, |
| 82 | - 'Key' => $key, | 82 | + 'Key' => ltrim($key,'/'), |
| 83 | 'Body' => $file_content, | 83 | 'Body' => $file_content, |
| 84 | ]); | 84 | ]); |
| 85 | return $result['ObjectURL']; | 85 | return $result['ObjectURL']; |
| 86 | -// } catch (AwsException $e) { | ||
| 87 | -// return '上传文件到S3时发生错误:' . $e->getMessage(); | ||
| 88 | -// } | 86 | + } catch (AwsException $e) { |
| 87 | + return '上传文件到S3时发生错误:' . $e->getMessage(); | ||
| 88 | + } | ||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | /** | 91 | /** |
-
请 注册 或 登录 后发表评论