From dc5c1d687a66504d30e56d9eb7c861676177cc2a Mon Sep 17 00:00:00 2001 From: trainliang Date: Fri, 7 Feb 2025 09:52:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9As3=E6=94=AF=E6=8C=81?= =?UTF-8?q?minio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/view/extend/upload/s3.html | 72 +++++++++++++------- application/common/extend/upload/S3.php | 11 ++- 2 files changed, 57 insertions(+), 26 deletions(-) diff --git a/application/admin/view/extend/upload/s3.html b/application/admin/view/extend/upload/s3.html index 1739510e..b5dc9190 100644 --- a/application/admin/view/extend/upload/s3.html +++ b/application/admin/view/extend/upload/s3.html @@ -1,26 +1,50 @@ -
- - -
{:lang('admin/system/configupload/s3_info')} {:lang('down')}{:lang('admin/system/configupload/s3_save_path')}:extend/aws/src/Aws/aws.phar
-
-
- -
- -
- -
- -
- -
- -
- -
- +
+ + +
{:lang('admin/system/configupload/s3_info')} {:lang('down')}{:lang('admin/system/configupload/s3_save_path')}:extend/aws/src/Aws/aws.phar +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
\ No newline at end of file diff --git a/application/common/extend/upload/S3.php b/application/common/extend/upload/S3.php index 59562cce..193dda7e 100644 --- a/application/common/extend/upload/S3.php +++ b/application/common/extend/upload/S3.php @@ -20,11 +20,16 @@ public function submit($file_path) $accessKey = $GLOBALS['config']['upload']['api']['s3']['accesskey']; $secretKey = $GLOBALS['config']['upload']['api']['s3']['secretkey']; $region = $GLOBALS['config']['upload']['api']['s3']['region']; + $endpoint = $GLOBALS['config']['upload']['api']['s3']['endpoint']; + $basepath = $GLOBALS['config']['upload']['api']['s3']['basepath']; + $domain = $GLOBALS['config']['upload']['api']['s3']['domain']; require_once ROOT_PATH . 'extend/aws/autoload.php'; $s3 = new S3Client([ 'region' => $region, 'version' => '2006-03-01', + 'endpoint' => $endpoint, + 'use_path_style_endpoint' => true, 'credentials' => [ 'key' => $accessKey, 'secret' => $secretKey @@ -34,7 +39,7 @@ public function submit($file_path) $filePath = ROOT_PATH . $file_path; $result = $s3->putObject([ 'Bucket' => $bucket, - 'Key' => $file_path, + 'Key' => $basepath . $file_path, 'Body' => fopen($filePath, 'r'), 'ACL' => 'public-read' ]); @@ -43,6 +48,8 @@ public function submit($file_path) } empty($this->config['keep_local']) && @unlink($filePath); - return $result['ObjectURL']; + // return $result['ObjectURL']; + // echo $result; + return $domain . $bucket . "/" . $basepath . $file_path; } }