作者 lyh

gx

... ... @@ -45,16 +45,16 @@ class AmazonS3Service
$key = $s3Key.'/'.$filename;
$body = fopen($files->getRealPath(), 'r');
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($body, true) . PHP_EOL, FILE_APPEND);
// try {
// $result = $this->s3->putObject([
// 'Bucket' => $this->bucket,
// 'Key' => $key,
// 'SourceFile' => $Body,
// 'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改
// ]);
// return $result['ObjectURL'];
// } catch (S3Exception $e) {
// return false;
// }
try {
$result = $this->s3->putObject([
'Bucket' => $this->bucket,
'Key' => $key,
'SourceFile' => $body,
'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改
]);
return $result['ObjectURL'];
} catch (S3Exception $e) {
return false;
}
}
}
... ...