|
...
|
...
|
@@ -40,20 +40,21 @@ class AmazonS3Service |
|
|
|
* @method :post
|
|
|
|
* @time :2024/1/23 9:20
|
|
|
|
*/
|
|
|
|
public function uploadFiles(&$files, $s3Key,$filename )
|
|
|
|
public function uploadFiles(&$files, $s3Key,$filename)
|
|
|
|
{
|
|
|
|
$key = $s3Key.'/'.$filename;
|
|
|
|
$Body = fopen($files->getRealPath(), 'r');
|
|
|
|
try {
|
|
|
|
$result = $this->s3->putObject([
|
|
|
|
'Bucket' => $this->bucket,
|
|
|
|
'Key' => $key,
|
|
|
|
'SourceFile' => $Body,
|
|
|
|
'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改
|
|
|
|
]);
|
|
|
|
return $result['ObjectURL'];
|
|
|
|
} catch (S3Exception $e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$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;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|