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 @@ -
- -
- 点击申请 https://aws.amazon.com/cn/s3 -
-
{: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; } }