diff --git a/app/Console/Commands/Upgrade/V11_0_0.php b/app/Console/Commands/Upgrade/V11_0_0.php index 550018ae3..566cad7b0 100644 --- a/app/Console/Commands/Upgrade/V11_0_0.php +++ b/app/Console/Commands/Upgrade/V11_0_0.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Upgrade; use Artisan; +use DB; use File; use Illuminate\Console\Command; @@ -29,5 +30,65 @@ public function handle() Artisan::call('storage:link --relative'); } + + $updatedConfigs = [ + 160 => 'filesystems.disks.oss_backups.access_key', + 161 => 'filesystems.disks.oss_backups.secret_key', + 162 => 'filesystems.disks.oss_backups.bucket', + 163 => 'filesystems.disks.oss_backups.endpoint', + ]; + + foreach ($updatedConfigs as $id => $name) { + DB::table('configs')->where('id', $id)->update([ + 'name' => $name, + ]); + } + + DB::table('configs')->where('id', 164)->update([ + 'value' => str_replace('"oss"', '"oss_backups"', DB::table('configs')->where('id', 164)->value('value')) + ]); + + DB::table('configs')->insertOrIgnore([ + [ + 'id' => 200, + 'name' => 'filesystems.disks.oss_uploads.access_key', + 'value' => '', + 'created_at' => '2020-06-26 23:29:52', + 'updated_at' => '2020-06-26 23:29:52', + 'deleted_at' => null, + ], + [ + 'id' => 201, + 'name' => 'filesystems.disks.oss_uploads.secret_key', + 'value' => '', + 'created_at' => '2020-06-26 23:29:52', + 'updated_at' => '2020-06-26 23:29:52', + 'deleted_at' => null, + ], + [ + 'id' => 202, + 'name' => 'filesystems.disks.oss_uploads.bucket', + 'value' => '', + 'created_at' => '2020-06-26 23:29:52', + 'updated_at' => '2020-06-26 23:29:52', + 'deleted_at' => null, + ], + [ + 'id' => 203, + 'name' => 'filesystems.disks.oss_uploads.endpoint', + 'value' => '', + 'created_at' => '2020-06-26 23:29:52', + 'updated_at' => '2020-06-26 23:29:52', + 'deleted_at' => null, + ], + [ + 'id' => 204, + 'name' => 'bjyblog.upload_disks', + 'value' => '["public"]', + 'created_at' => '2018-12-04 22:29:52', + 'updated_at' => '2018-12-04 22:29:52', + 'deleted_at' => null, + ], + ]); } } diff --git a/app/Http/Controllers/Admin/ArticleController.php b/app/Http/Controllers/Admin/ArticleController.php index 0c924935a..c5dfade6c 100644 --- a/app/Http/Controllers/Admin/ArticleController.php +++ b/app/Http/Controllers/Admin/ArticleController.php @@ -51,7 +51,9 @@ public function create() public function uploadImage(Request $request) { - $imagePath = $request->file('editormd-image-file')->store('uploads/article/' . Date::now()->format('Ymd'), 'public'); + foreach (config('bjyblog.upload_disks') as $disk) { + $imagePath = $request->file('editormd-image-file')->store('uploads/article/' . Date::now()->format('Ymd'), $disk); + } return response()->json([ 'success' => 1, @@ -65,7 +67,10 @@ public function store(Store $request) $article = $request->except('_token'); if ($request->hasFile('cover')) { - $imagePath = $request->file('cover')->store('uploads/article/' . Date::now()->format('Ymd'), 'public'); + foreach (config('bjyblog.upload_disks') as $disk) { + $imagePath = $request->file('cover')->store('uploads/article/' . Date::now()->format('Ymd'), $disk); + } + $article['cover'] = '/' . $imagePath; } @@ -95,7 +100,10 @@ public function update(Store $request, ArticleTag $articleTagModel, $id) // 上传封面图 if ($request->hasFile('cover')) { - $imagePath = $request->file('cover')->store('uploads/article/' . Date::now()->format('Ymd'), 'public'); + foreach (config('bjyblog.upload_disks') as $disk) { + $imagePath = $request->file('cover')->store('uploads/article/' . Date::now()->format('Ymd'), $disk); + } + $article['cover'] = '/' . $imagePath; } diff --git a/app/Http/Controllers/Admin/ConfigController.php b/app/Http/Controllers/Admin/ConfigController.php index 07968b3d5..689524e8e 100644 --- a/app/Http/Controllers/Admin/ConfigController.php +++ b/app/Http/Controllers/Admin/ConfigController.php @@ -36,6 +36,11 @@ public function backup() return view('admin.config.backup'); } + public function upload() + { + return view('admin.config.upload'); + } + public function seo() { return view('admin.config.seo'); @@ -71,7 +76,10 @@ public function update(Request $request) $configs = $request->except('_token'); if ($request->hasFile('153')) { - $imagePath = $request->file('153')->store('uploads/images', 'public'); + foreach (config('bjyblog.upload_disks') as $disk) { + $imagePath = $request->file('153')->store('uploads/images', $disk); + } + $configs['153'] = '/' . $imagePath; } diff --git a/app/Http/Controllers/Resources/ArticleCoverController.php b/app/Http/Controllers/Resources/ArticleCoverController.php index 3991ec575..b78122bc8 100644 --- a/app/Http/Controllers/Resources/ArticleCoverController.php +++ b/app/Http/Controllers/Resources/ArticleCoverController.php @@ -11,7 +11,9 @@ class ArticleCoverController extends Controller { public function store(Store $request) { - $imagePath = $request->file('cover')->store('uploads/article' . Date::now()->format('Ymd'), 'public'); + foreach (config('bjyblog.upload_disks') as $disk) { + $imagePath = $request->file('cover')->store('uploads/article/' . Date::now()->format('Ymd'), $disk); + } return response()->json([ 'success' => 1, diff --git a/app/Http/Controllers/Resources/ConfigController.php b/app/Http/Controllers/Resources/ConfigController.php index 88cbcc0cc..36900fb5a 100644 --- a/app/Http/Controllers/Resources/ConfigController.php +++ b/app/Http/Controllers/Resources/ConfigController.php @@ -17,7 +17,9 @@ class ConfigController extends Controller public function uploadQqQunOrCode(QqQunOrCode $request) { - $imagePath = $request->file('file')->store('uploads/images', 'public'); + foreach (config('bjyblog.upload_disks') as $disk) { + $imagePath = $request->file('file')->store('uploads/images', $disk); + } return response()->json([ 'url' => $imagePath, diff --git a/config/bjyblog.php b/config/bjyblog.php index 655c16091..682b8c54c 100644 --- a/config/bjyblog.php +++ b/config/bjyblog.php @@ -63,4 +63,5 @@ 'language' => '', ], 'theme' => '', + 'upload_disks' => '', ]; diff --git a/config/filesystems.php b/config/filesystems.php index 4faf3e4da..abc7f6184 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -64,14 +64,24 @@ 'url' => env('AWS_URL'), ], - 'oss' => [ + 'oss_backups' => [ 'driver' => 'oss', 'root' => '', - 'access_key' => env('OSS_ACCESS_KEY'), - 'secret_key' => env('OSS_SECRET_KEY'), - 'endpoint' => env('OSS_ENDPOINT'), - 'bucket' => env('OSS_BUCKET'), - 'isCName' => env('OSS_IS_CNAME', false), + 'access_key' => '', + 'secret_key' => '', + 'endpoint' => '', + 'bucket' => '', + 'isCName' => false, + ], + + 'oss_uploads' => [ + 'driver' => 'oss', + 'root' => '', + 'access_key' => '', + 'secret_key' => '', + 'endpoint' => '', + 'bucket' => '', + 'isCName' => false, ], ], diff --git a/database/seeds/ConfigsTableSeeder.php b/database/seeds/ConfigsTableSeeder.php index ea3ee7c76..ea27bfbc6 100644 --- a/database/seeds/ConfigsTableSeeder.php +++ b/database/seeds/ConfigsTableSeeder.php @@ -250,7 +250,7 @@ public function run() ], [ 'id' => 160, - 'name' => 'filesystems.disks.oss.access_key', + 'name' => 'filesystems.disks.oss_backups.access_key', 'value' => '', 'created_at' => '2018-12-04 22:29:52', 'updated_at' => '2018-12-04 22:29:52', @@ -258,7 +258,7 @@ public function run() ], [ 'id' => 161, - 'name' => 'filesystems.disks.oss.secret_key', + 'name' => 'filesystems.disks.oss_backups.secret_key', 'value' => '', 'created_at' => '2018-12-04 22:29:52', 'updated_at' => '2018-12-04 22:29:52', @@ -266,7 +266,7 @@ public function run() ], [ 'id' => 162, - 'name' => 'filesystems.disks.oss.bucket', + 'name' => 'filesystems.disks.oss_backups.bucket', 'value' => '', 'created_at' => '2018-12-04 22:29:52', 'updated_at' => '2018-12-04 22:29:52', @@ -274,7 +274,7 @@ public function run() ], [ 'id' => 163, - 'name' => 'filesystems.disks.oss.endpoint', + 'name' => 'filesystems.disks.oss_backups.endpoint', 'value' => '', 'created_at' => '2018-12-04 22:29:52', 'updated_at' => '2018-12-04 22:29:52', @@ -575,6 +575,46 @@ public function run() 'updated_at' => '2020-05-12 23:06:00', 'deleted_at' => null, ], + [ + 'id' => 200, + 'name' => 'filesystems.disks.oss_uploads.access_key', + 'value' => '', + 'created_at' => '2020-06-26 23:29:52', + 'updated_at' => '2020-06-26 23:29:52', + 'deleted_at' => null, + ], + [ + 'id' => 201, + 'name' => 'filesystems.disks.oss_uploads.secret_key', + 'value' => '', + 'created_at' => '2020-06-26 23:29:52', + 'updated_at' => '2020-06-26 23:29:52', + 'deleted_at' => null, + ], + [ + 'id' => 202, + 'name' => 'filesystems.disks.oss_uploads.bucket', + 'value' => '', + 'created_at' => '2020-06-26 23:29:52', + 'updated_at' => '2020-06-26 23:29:52', + 'deleted_at' => null, + ], + [ + 'id' => 203, + 'name' => 'filesystems.disks.oss_uploads.endpoint', + 'value' => '', + 'created_at' => '2020-06-26 23:29:52', + 'updated_at' => '2020-06-26 23:29:52', + 'deleted_at' => null, + ], + [ + 'id' => 204, + 'name' => 'bjyblog.upload_disks', + 'value' => '["public"]', + 'created_at' => '2018-12-04 22:29:52', + 'updated_at' => '2018-12-04 22:29:52', + 'deleted_at' => null, + ], ]); } } diff --git a/resources/lang/fr.json b/resources/lang/fr.json index 2eedc7394..8b27d4d00 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -205,6 +205,7 @@ "URL": "URL", "Update Success": "Mise à jour réussie", "Upgrade": "Améliorer", + "Upload": "Télécharger", "Use Slug": "Utilisation Slug", "User": "Utilisateur", "User Counts": "Nombre utilisateurs", diff --git a/resources/lang/ru.json b/resources/lang/ru.json index 9675bd22f..3d2aa183f 100644 --- a/resources/lang/ru.json +++ b/resources/lang/ru.json @@ -205,6 +205,7 @@ "URL": "URL", "Update Success": "Успешно обновлено", "Upgrade": "Обновление", + "Upload": "Загрузить", "Use Slug": "Использовать слаги", "User": "Пользователи", "User Counts": "Количество пользователей", diff --git a/resources/lang/zh-CN.json b/resources/lang/zh-CN.json index 26f4cc49d..8cdfa9f92 100644 --- a/resources/lang/zh-CN.json +++ b/resources/lang/zh-CN.json @@ -205,6 +205,7 @@ "URL": "链接", "Update Success": "修改成功", "Upgrade": "升级", + "Upload": "上传", "Use Slug": "使用 Slug", "User": "用户", "User Counts": "登录用户", diff --git a/resources/views/admin/config/backup.blade.php b/resources/views/admin/config/backup.blade.php index 7d5d241b2..6d7becc18 100644 --- a/resources/views/admin/config/backup.blade.php +++ b/resources/views/admin/config/backup.blade.php @@ -13,7 +13,7 @@