From 4590728cb1a7fc0740a7daa8692ac61e2dfffc16 Mon Sep 17 00:00:00 2001 From: gzydong <837215079@qq.com> Date: Wed, 30 Jun 2021 19:27:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Command/TestCommand.php | 3 + app/Controller/Api/V1/ArticleController.php | 36 ++++----- app/Controller/Api/V1/DownloadController.php | 25 ++++--- app/Controller/Api/V1/EmoticonController.php | 20 ++--- app/Controller/Api/V1/TalkController.php | 31 ++++---- app/Controller/Api/V1/UploadController.php | 28 ++++--- app/Service/SplitUploadService.php | 48 +++++------- app/Service/UploadService.php | 51 ------------- app/Support/MailerTemplate.php | 3 +- app/helper.php | 21 ++++-- config/autoload/file.php | 78 ++++++++++---------- config/config.php | 8 +- storage/view/emails/error-notice.blade.php | 1 + 13 files changed, 147 insertions(+), 206 deletions(-) delete mode 100644 app/Service/UploadService.php diff --git a/app/Command/TestCommand.php b/app/Command/TestCommand.php index 97c414d..4645e0f 100644 --- a/app/Command/TestCommand.php +++ b/app/Command/TestCommand.php @@ -24,6 +24,7 @@ use App\Model\Group\GroupMember; use App\Service\TalkService; use Hyperf\Command\Command as HyperfCommand; use Hyperf\Command\Annotation\Command; +use League\Flysystem\Filesystem; use Psr\Container\ContainerInterface; /** @@ -173,5 +174,7 @@ class TestCommand extends HyperfCommand //var_dump(FriendRemark::getInstance()); //var_dump(Group::isManager(2054,116)); + + var_dump(pathinfo('spring-boot相关',PATHINFO_EXTENSION)); } } diff --git a/app/Controller/Api/V1/ArticleController.php b/app/Controller/Api/V1/ArticleController.php index f1a4616..8272c3e 100644 --- a/app/Controller/Api/V1/ArticleController.php +++ b/app/Controller/Api/V1/ArticleController.php @@ -16,8 +16,7 @@ use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\HttpServer\Annotation\Middleware; use App\Middleware\JWTAuthMiddleware; use App\Service\ArticleService; -use App\Service\UploadService; -use Hyperf\Utils\Str; +use League\Flysystem\Filesystem; use Psr\Http\Message\ResponseInterface; use App\Cache\Repository\LockRedis; @@ -36,12 +35,6 @@ class ArticleController extends CController */ private $articleService; - /** - * @inject - * @var UploadService - */ - private $uploadService; - /** * 获取笔记分类列表 * @RequestMapping(path="article-class", methods="get") @@ -180,7 +173,6 @@ class ArticleController extends CController $lockKey = "article:sort_{$params['class_id']}_{$params['sort_type']}"; - // 获取Redis锁 $lock = LockRedis::getInstance(); if ($lock->lock($lockKey, 3, 500)) { $isTrue = $this->articleService->articleClassSort($this->uid(), (int)$params['class_id'], (int)$params['sort_type']); @@ -332,9 +324,10 @@ class ArticleController extends CController * 笔记图片上传接口 * @RequestMapping(path="upload-article-image", methods="post") * + * @param Filesystem $filesystem * @return ResponseInterface */ - public function uploadArticleImage() + public function uploadArticleImage(Filesystem $filesystem) { $file = $this->request->file('image'); if (!$file || !$file->isValid()) { @@ -346,10 +339,10 @@ class ArticleController extends CController return $this->response->fail('图片格式错误,目前仅支持jpg、png、jpeg、gif和webp'); } - $imgInfo = getimagesize($file->getRealPath()); - - $path = $this->uploadService->media($file, 'media/images/notes/', create_image_name($ext, $imgInfo[0], $imgInfo[1])); - if (!$path) { + try { + $path = 'media/images/notes/' . date('Ymd') . '/' . create_image_name($ext, getimagesize($file->getRealPath())); + $filesystem->write($path, file_get_contents($file->getRealPath())); + } catch (\Exception $e) { return $this->response->fail(); } @@ -456,7 +449,7 @@ class ArticleController extends CController * * @return ResponseInterface */ - public function uploadArticleAnnex() + public function uploadArticleAnnex(Filesystem $filesystem) { $params = $this->request->inputs(['article_id']); $this->validate($params, [ @@ -469,23 +462,22 @@ class ArticleController extends CController } $annex = [ - 'file_suffix' => $file->getExtension(), + 'file_suffix' => pathinfo($file->getClientFilename(), PATHINFO_EXTENSION), 'file_size' => $file->getSize(), 'save_dir' => '', 'original_name' => $file->getClientFilename() ]; - $path = $this->uploadService->media($file, - 'files/notes/' . date('Ymd'), - "[{$annex['file_suffix']}]" . uniqid() . Str::random(16) . '.' . 'tmp' - ); - - if (!$path) { + try { + $path = 'files/notes/' . date('Ymd') . '/' . "[{$annex['file_suffix']}]" . create_random_filename('tmp'); + $filesystem->write($path, file_get_contents($file->getRealPath())); + } catch (\Exception $e) { return $this->response->fail(); } $annex['save_dir'] = $path; $annex['id'] = $this->articleService->insertArticleAnnex($this->uid(), (int)$params['article_id'], $annex); + if (!$annex['id']) { return $this->response->fail('附件上传失败,请稍后再试!'); } diff --git a/app/Controller/Api/V1/DownloadController.php b/app/Controller/Api/V1/DownloadController.php index be6d15f..ba97bc8 100644 --- a/app/Controller/Api/V1/DownloadController.php +++ b/app/Controller/Api/V1/DownloadController.php @@ -19,8 +19,8 @@ use App\Model\Article\ArticleAnnex; use App\Model\Chat\ChatRecord; use App\Model\Chat\ChatRecordsFile; use App\Model\Group\Group; -use App\Service\UploadService; use Hyperf\HttpServer\Contract\ResponseInterface; +use League\Flysystem\Filesystem; /** * Class DownloadController @@ -31,15 +31,20 @@ use Hyperf\HttpServer\Contract\ResponseInterface; */ class DownloadController extends CController { + private function getFilePath(string $path) + { + return container()->get(Filesystem::class)->getConfig()->get('root') . '/' . $path; + } + /** * 下载用户聊天文件 * @RequestMapping(path="user-chat-file", methods="get") * * @param ResponseInterface $response - * @param UploadService $uploadService + * @param Filesystem $filesystem * @return \Psr\Http\Message\ResponseInterface */ - public function userChatFile(ResponseInterface $response, UploadService $uploadService) + public function userChatFile(ResponseInterface $response, Filesystem $filesystem) { $params = $this->request->inputs(['cr_id']); $this->validate($params, [ @@ -66,12 +71,12 @@ class DownloadController extends CController } } - $fileInfo = ChatRecordsFile::select(['save_dir', 'original_name'])->where('record_id', $params['cr_id'])->first(); - if (!$fileInfo || !file_exists($uploadService->driver($fileInfo->save_dir))) { + $info = ChatRecordsFile::select(['save_dir', 'original_name'])->where('record_id', $params['cr_id'])->first(); + if (!$info || !$filesystem->has($info->save_dir)) { return $this->response->fail('文件不存在或没有下载权限!'); } - return $response->download($uploadService->driver($fileInfo->save_dir), $fileInfo->original_name); + return $response->download($this->getFilePath($info->save_dir), $info->original_name); } /** @@ -79,10 +84,10 @@ class DownloadController extends CController * @RequestMapping(path="article-annex", methods="get") * * @param ResponseInterface $response - * @param UploadService $uploadService + * @param Filesystem $filesystem * @return \Psr\Http\Message\ResponseInterface */ - public function articleAnnex(ResponseInterface $response, UploadService $uploadService) + public function articleAnnex(ResponseInterface $response, Filesystem $filesystem) { $params = $this->request->inputs(['annex_id']); $this->validate($params, [ @@ -94,10 +99,10 @@ class DownloadController extends CController ->where('user_id', $this->uid()) ->first(); - if (!$info || !file_exists($uploadService->driver($info->save_dir))) { + if (!$info || !$filesystem->has($info->save_dir)) { return $this->response->fail('文件不存在或没有下载权限!'); } - return $response->download($uploadService->driver($info->save_dir), $info->original_name); + return $response->download($this->getFilePath($info->save_dir), $info->original_name); } } diff --git a/app/Controller/Api/V1/EmoticonController.php b/app/Controller/Api/V1/EmoticonController.php index 7c152a1..de4d776 100644 --- a/app/Controller/Api/V1/EmoticonController.php +++ b/app/Controller/Api/V1/EmoticonController.php @@ -19,7 +19,7 @@ use App\Constants\ResponseCode; use App\Model\Emoticon; use App\Model\EmoticonDetail; use App\Service\EmoticonService; -use App\Service\UploadService; +use League\Flysystem\Filesystem; use Psr\Http\Message\ResponseInterface; /** @@ -143,10 +143,10 @@ class EmoticonController extends CController * 自定义上传表情包 * @RequestMapping(path="upload-emoticon", methods="post") * - * @param UploadService $uploadService + * @param Filesystem $filesystem * @return ResponseInterface */ - public function uploadEmoticon(UploadService $uploadService) + public function uploadEmoticon(Filesystem $filesystem) { $file = $this->request->file('emoticon'); if (!$file->isValid()) { @@ -164,20 +164,16 @@ class EmoticonController extends CController ); } - // 读取图片信息 - $imgInfo = @getimagesize($file->getRealPath()); - if (!$imgInfo) { - return $this->response->fail('表情包上传失败!'); - } - - $save_path = $uploadService->media($file, 'media/images/emoticon', create_image_name($ext, $imgInfo[0], $imgInfo[1])); - if (!$save_path) { + try { + $path = 'media/images/emoticon/' . date('Ymd') . '/' . create_image_name($ext, getimagesize($file->getRealPath())); + $filesystem->write($path, file_get_contents($file->getRealPath())); + } catch (\Exception $e) { return $this->response->fail('图片上传失败!'); } $result = EmoticonDetail::create([ 'user_id' => $this->uid(), - 'url' => $save_path, + 'url' => $path, 'file_suffix' => $ext, 'file_size' => $file->getSize(), 'created_at' => time() diff --git a/app/Controller/Api/V1/TalkController.php b/app/Controller/Api/V1/TalkController.php index 83ae275..277fd44 100644 --- a/app/Controller/Api/V1/TalkController.php +++ b/app/Controller/Api/V1/TalkController.php @@ -17,7 +17,6 @@ use Hyperf\HttpServer\Annotation\Controller; use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\HttpServer\Annotation\Middleware; use App\Middleware\JWTAuthMiddleware; -use Hyperf\Utils\Str; use Psr\Http\Message\ResponseInterface; use App\Model\EmoticonDetail; use App\Model\FileSplitUpload; @@ -26,9 +25,9 @@ use App\Model\UsersChatList; use App\Model\UsersFriend; use App\Model\Group\Group; use App\Service\TalkService; -use App\Service\UploadService; use App\Amqp\Producer\ChatMessageProducer; use App\Constants\SocketConstants; +use League\Flysystem\Filesystem; /** * Class TalkController @@ -475,10 +474,10 @@ class TalkController extends CController * 上传聊天对话图片(待优化) * @RequestMapping(path="send-image", methods="post") * - * @param UploadService $uploadService + * @param Filesystem $filesystem * @return ResponseInterface */ - public function sendImage(UploadService $uploadService) + public function sendImage(Filesystem $filesystem) { $params = $this->request->inputs(['source', 'receive_id']); $this->validate($params, [ @@ -496,11 +495,10 @@ class TalkController extends CController return $this->response->fail('图片格式错误,目前仅支持jpg、png、jpeg、gif和webp'); } - // 获取图片信息 - $imgInfo = getimagesize($file->getRealPath()); - - $path = $uploadService->media($file, 'media/images/talks', create_image_name($ext, $imgInfo[0], $imgInfo[1])); - if (!$path) { + try { + $path = 'media/images/talks/' . date('Ymd') . '/' . create_image_name($ext, getimagesize($file->getRealPath())); + $filesystem->write($path, file_get_contents($file->getRealPath())); + } catch (\Exception $e) { return $this->response->fail(); } @@ -593,10 +591,10 @@ class TalkController extends CController * 发送文件消息 * @RequestMapping(path="send-file", methods="post") * - * @param UploadService $uploadService + * @param Filesystem $filesystem * @return ResponseInterface */ - public function sendFile(UploadService $uploadService) + public function sendFile(Filesystem $filesystem) { $params = $this->request->inputs(['hash_name', 'receive_id', 'source']); $this->validate($params, [ @@ -612,12 +610,13 @@ class TalkController extends CController return $this->response->fail('文件不存在...'); } - $file_hash_name = uniqid() . Str::random(10) . '.' . $file->file_ext; - $save_dir = "files/talks/" . date('Ymd') . '/' . $file_hash_name; + $save_dir = "files/talks/" . date('Ymd') . '/' . create_random_filename($file->file_ext); - $uploadService->makeDirectory($uploadService->driver("files/talks/" . date('Ymd'))); - - @copy($uploadService->driver($file->save_dir), $uploadService->driver($save_dir)); + try { + $filesystem->copy($file->save_dir, $save_dir); + } catch (\Exception $e) { + return $this->response->fail('文件不存在...'); + } $record_id = $this->talkService->createFileMessage([ 'source' => $params['source'], diff --git a/app/Controller/Api/V1/UploadController.php b/app/Controller/Api/V1/UploadController.php index f1380fb..3bf80ea 100644 --- a/app/Controller/Api/V1/UploadController.php +++ b/app/Controller/Api/V1/UploadController.php @@ -17,12 +17,11 @@ use Hyperf\HttpServer\Annotation\RequestMapping; use Hyperf\HttpServer\Annotation\Middleware; use App\Middleware\JWTAuthMiddleware; use App\Service\SplitUploadService; -use App\Service\UploadService; +use League\Flysystem\Filesystem; use Psr\Http\Message\ResponseInterface; /** - * 上传控制器 - * Class UploadController + * 上传文件控制器 * @Controller(path="/api/v1/upload") * @Middleware(JWTAuthMiddleware::class) * @@ -30,12 +29,6 @@ use Psr\Http\Message\ResponseInterface; */ class UploadController extends CController { - /** - * @inject - * @var UploadService - */ - private $uploadService; - /** * @inject * @var SplitUploadService @@ -48,14 +41,19 @@ class UploadController extends CController * * @return ResponseInterface */ - public function fileStream() + public function fileStream(Filesystem $filesystem) { $fileStream = $this->request->post('fileStream', ''); - $data = base64_decode(str_replace(['data:image/png;base64,', ' '], ['', '+'], $fileStream)); + if (empty($fileStream)) { + return $this->response->fail(); + } - $path = '/media/images/avatar/' . date('Ymd') . '/' . uniqid() . date('His') . '.png'; - $this->uploadService->makeDirectory($this->uploadService->driver('/media/images/avatar/' . date('Ymd') . '/')); - @file_put_contents($this->uploadService->driver($path), $data); + $path = 'media/images/avatar/' . date('Ymd') . '/' . create_random_filename('png'); + try { + $filesystem->write($path, base64_decode(str_replace(['data:image/png;base64,', ' '], ['', '+'], $fileStream))); + } catch (\Exception $e) { + return $this->response->fail(); + } return $this->response->success(['avatar' => get_media_url($path)]); } @@ -105,7 +103,7 @@ class UploadController extends CController $user_id = $this->uid(); $uploadRes = $this->splitUploadService->upload($user_id, $file, $params['hash'], intval($params['split_index']), intval($params['size'])); if (!$uploadRes) { - return $this->response->fail('上传文件失败!'); + return $this->response->fail('上传文件失败111!'); } if (($params['split_index'] + 1) == $params['split_num']) { diff --git a/app/Service/SplitUploadService.php b/app/Service/SplitUploadService.php index 3027727..c2effc6 100644 --- a/app/Service/SplitUploadService.php +++ b/app/Service/SplitUploadService.php @@ -5,6 +5,7 @@ namespace App\Service; use App\Model\FileSplitUpload; use Hyperf\Utils\Str; use Hyperf\HttpMessage\Upload\UploadedFile; +use League\Flysystem\Filesystem; /** * 文件拆分上传服务 @@ -63,18 +64,12 @@ class SplitUploadService ->where([['user_id', '=', $user_id], ['hash_name', '=', $hashName], ['file_type', '=', 1]]) ->first(); - if (!$fileInfo) { - return false; - } + if (!$fileInfo) return false; - // 保存文件名及保存文件相对目录 - $fileName = "{$hashName}_{$split_index}_{$fileInfo->file_ext}.tmp"; - $uploadService = make(UploadService::class); - - $uploadService->makeDirectory($uploadService->driver("tmp/{$hashName}")); - $file->moveTo(sprintf('%s/%s', $uploadService->driver("tmp/{$hashName}"), $fileName)); - - if (!$file->isMoved()) { + $save_path = "tmp/{$hashName}/" . "{$hashName}_{$split_index}_{$fileInfo->file_ext}.tmp"; + try { + container()->get(Filesystem::class)->write($save_path, file_get_contents($file->getRealPath())); + } catch (\Exception $e) { return false; } @@ -87,7 +82,7 @@ class SplitUploadService 'original_name' => $fileInfo->original_name, 'split_index' => $split_index, 'split_num' => $fileInfo->split_num, - 'save_dir' => sprintf('%s/%s', "tmp/{$hashName}", $fileName), + 'save_dir' => $save_path, 'file_ext' => $fileInfo->file_ext, 'file_size' => $fileSize, 'upload_at' => time(), @@ -112,9 +107,7 @@ class SplitUploadService ->where('file_type', 1) ->first(); - if (!$fileInfo) { - return false; - } + if (!$fileInfo) return false; $files = FileSplitUpload::where('user_id', $user_id) ->where('hash_name', $hash_name) @@ -122,30 +115,27 @@ class SplitUploadService ->orderBy('split_index', 'asc') ->get(['split_index', 'save_dir'])->toArray(); - if (!$files) { - return false; - } + if (!$files || count($files) != $fileInfo->split_num) return false; - if (count($files) != $fileInfo->split_num) { - return false; - } + $file_merge = "tmp/{$hash_name}/{$fileInfo->original_name}.tmp"; - $fileMerge = "tmp/{$hash_name}/{$fileInfo->original_name}.tmp"; - $uploadService = make(UploadService::class); - - // 文件合并 - $merge_save_path = $uploadService->driver($fileMerge); + $filesystem = container()->get(Filesystem::class); + $root_path = $filesystem->getConfig()->get('root'); foreach ($files as $file) { - file_put_contents($merge_save_path, file_get_contents($uploadService->driver($file['save_dir'])), FILE_APPEND); + file_put_contents( + "{$root_path}/{$file_merge}", + $filesystem->read($file['save_dir']), + FILE_APPEND + ); } FileSplitUpload::select(['id', 'original_name', 'split_num', 'file_ext', 'file_size']) ->where('user_id', $user_id)->where('hash_name', $hash_name) ->where('file_type', 1) - ->update(['save_dir' => $fileMerge]); + ->update(['save_dir' => $file_merge]); return [ - 'path' => $fileMerge, + 'path' => $file_merge, 'tmp_file_name' => "{$fileInfo->original_name}.tmp", 'original_name' => $fileInfo->original_name, 'file_size' => $fileInfo->file_size diff --git a/app/Service/UploadService.php b/app/Service/UploadService.php deleted file mode 100644 index 1c22430..0000000 --- a/app/Service/UploadService.php +++ /dev/null @@ -1,51 +0,0 @@ -driver($dir); - - $this->makeDirectory($save_dir); - - $file->moveTo(sprintf('%s/%s', $save_dir, $filename)); - - if ($file->isMoved()) { - @chmod(sprintf('%s/%s', $save_dir, $filename), 0644); - } - - return $file->isMoved() ? sprintf('%s/%s', trim($dir, '/'), $filename) : false; - } -} diff --git a/app/Support/MailerTemplate.php b/app/Support/MailerTemplate.php index 3f5990c..b125dce 100644 --- a/app/Support/MailerTemplate.php +++ b/app/Support/MailerTemplate.php @@ -49,7 +49,8 @@ class MailerTemplate public function errorNotice(Throwable $throwable) { return $this->view(config('view.engine'), 'emails.error-notice', [ - 'throwable' => $throwable->getTraceAsString() + 'throwable' => $throwable->getTraceAsString(), + 'message' => $throwable->getMessage() ]); } } diff --git a/app/helper.php b/app/helper.php index 03c8523..a074f4f 100644 --- a/app/helper.php +++ b/app/helper.php @@ -180,14 +180,13 @@ function get_media_url(string $path) /** * 随机生成图片名 * - * @param string $ext 图片后缀名 - * @param int $width 图片宽度 - * @param int $height 图片高度 + * @param string $ext 图片后缀名 + * @param array $filesize 图片文件大小信息 * @return string */ -function create_image_name(string $ext, int $width, int $height) +function create_image_name(string $ext, array $filesize) { - return uniqid() . Str::random() . '_' . $width . 'x' . $height . '.' . $ext; + return uniqid() . Str::random() . '_' . $filesize[0] . 'x' . $filesize[1] . '.' . $ext; } /** @@ -255,4 +254,14 @@ function push_amqp(ProducerMessage $message, bool $confirm = false, int $timeout return container()->get(Producer::class)->produce($message, $confirm, $timeout); } - +/** + * 生成随机文件名 + * + * @param string $ext 文件后缀名 + * @return string + */ +function create_random_filename(string $ext) +{ + $ext = $ext ? '.' . $ext : ''; + return Str::random(10) . uniqid() . $ext; +} diff --git a/config/autoload/file.php b/config/autoload/file.php index 59cd236..c04dfff 100644 --- a/config/autoload/file.php +++ b/config/autoload/file.php @@ -12,13 +12,13 @@ declare(strict_types=1); return [ 'default' => 'local', 'storage' => [ - 'local' => [ + 'local' => [ 'driver' => \Hyperf\Filesystem\Adapter\LocalAdapterFactory::class, - 'root' => __DIR__ . '/../../runtime', + 'root' => env('UPLOAD_PATH', __DIR__ . '/../../runtime'), ], - 'ftp' => [ - 'driver' => \Hyperf\Filesystem\Adapter\FtpAdapterFactory::class, - 'host' => 'ftp.example.com', + 'ftp' => [ + 'driver' => \Hyperf\Filesystem\Adapter\FtpAdapterFactory::class, + 'host' => 'ftp.example.com', 'username' => 'username', 'password' => 'password', // 'port' => 21, @@ -31,59 +31,59 @@ return [ 'memory' => [ 'driver' => \Hyperf\Filesystem\Adapter\MemoryAdapterFactory::class, ], - 's3' => [ - 'driver' => \Hyperf\Filesystem\Adapter\S3AdapterFactory::class, - 'credentials' => [ - 'key' => env('S3_KEY'), + 's3' => [ + 'driver' => \Hyperf\Filesystem\Adapter\S3AdapterFactory::class, + 'credentials' => [ + 'key' => env('S3_KEY'), 'secret' => env('S3_SECRET'), ], - 'region' => env('S3_REGION'), - 'version' => 'latest', - 'bucket_endpoint' => false, + 'region' => env('S3_REGION'), + 'version' => 'latest', + 'bucket_endpoint' => false, 'use_path_style_endpoint' => false, - 'endpoint' => env('S3_ENDPOINT'), - 'bucket_name' => env('S3_BUCKET'), + 'endpoint' => env('S3_ENDPOINT'), + 'bucket_name' => env('S3_BUCKET'), ], - 'minio' => [ - 'driver' => \Hyperf\Filesystem\Adapter\S3AdapterFactory::class, - 'credentials' => [ - 'key' => env('S3_KEY'), + 'minio' => [ + 'driver' => \Hyperf\Filesystem\Adapter\S3AdapterFactory::class, + 'credentials' => [ + 'key' => env('S3_KEY'), 'secret' => env('S3_SECRET'), ], - 'region' => env('S3_REGION'), - 'version' => 'latest', - 'bucket_endpoint' => false, + 'region' => env('S3_REGION'), + 'version' => 'latest', + 'bucket_endpoint' => false, 'use_path_style_endpoint' => true, - 'endpoint' => env('S3_ENDPOINT'), - 'bucket_name' => env('S3_BUCKET'), + 'endpoint' => env('S3_ENDPOINT'), + 'bucket_name' => env('S3_BUCKET'), ], - 'oss' => [ - 'driver' => \Hyperf\Filesystem\Adapter\AliyunOssAdapterFactory::class, - 'accessId' => env('OSS_ACCESS_ID'), + 'oss' => [ + 'driver' => \Hyperf\Filesystem\Adapter\AliyunOssAdapterFactory::class, + 'accessId' => env('OSS_ACCESS_ID'), 'accessSecret' => env('OSS_ACCESS_SECRET'), - 'bucket' => env('OSS_BUCKET'), - 'endpoint' => env('OSS_ENDPOINT'), + 'bucket' => env('OSS_BUCKET'), + 'endpoint' => env('OSS_ENDPOINT'), // 'timeout' => 3600, // 'connectTimeout' => 10, // 'isCName' => false, // 'token' => '', ], - 'qiniu' => [ - 'driver' => \Hyperf\Filesystem\Adapter\QiniuAdapterFactory::class, + 'qiniu' => [ + 'driver' => \Hyperf\Filesystem\Adapter\QiniuAdapterFactory::class, 'accessKey' => env('QINIU_ACCESS_KEY'), 'secretKey' => env('QINIU_SECRET_KEY'), - 'bucket' => env('QINIU_BUCKET'), - 'domain' => env('QINBIU_DOMAIN'), + 'bucket' => env('QINIU_BUCKET'), + 'domain' => env('QINBIU_DOMAIN'), ], - 'cos' => [ - 'driver' => \Hyperf\Filesystem\Adapter\CosAdapterFactory::class, - 'region' => env('COS_REGION'), - 'credentials' => [ - 'appId' => env('COS_APPID'), - 'secretId' => env('COS_SECRET_ID'), + 'cos' => [ + 'driver' => \Hyperf\Filesystem\Adapter\CosAdapterFactory::class, + 'region' => env('COS_REGION'), + 'credentials' => [ + 'appId' => env('COS_APPID'), + 'secretId' => env('COS_SECRET_ID'), 'secretKey' => env('COS_SECRET_KEY'), ], - 'bucket' => env('COS_BUCKET'), + 'bucket' => env('COS_BUCKET'), 'read_from_cdn' => false, // 'timeout' => 60, // 'connect_timeout' => 60, diff --git a/config/config.php b/config/config.php index b8463ea..a575a0e 100644 --- a/config/config.php +++ b/config/config.php @@ -21,14 +21,12 @@ return [ // 域名相关配置 'domain' => [ - 'web_url' => env('WEB_URL', ''),//Web 端首页地址 - 'img_url' => env('IMG_URL', ''),//设置文件图片访问的域名 + 'web_url' => env('WEB_URL', ''),// Web 端首页地址 + 'img_url' => env('IMG_URL', ''),// 设置文件图片访问的域名 ], - 'upload_dir' => env('UPLOAD_PATH', ''), - // 管理员邮箱 - 'admin_email' => env('ADMIN_EMAIL', ''), + 'admin_email' => env('ADMIN_EMAIL', ''), StdoutLoggerInterface::class => [ 'log_level' => [ diff --git a/storage/view/emails/error-notice.blade.php b/storage/view/emails/error-notice.blade.php index 4fa9fca..dcfdd22 100644 --- a/storage/view/emails/error-notice.blade.php +++ b/storage/view/emails/error-notice.blade.php @@ -70,6 +70,7 @@
+

{{$message}}

{{$throwable}}