mirror of
https://github.com/PhyreApps/PhyrePanel.git
synced 2024-11-25 09:00:27 +00:00
update
This commit is contained in:
parent
dd3c93db37
commit
d25cff070d
5 changed files with 54 additions and 0 deletions
|
@ -14,6 +14,8 @@ use Filament\Forms\Get;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Support\Number;
|
use Illuminate\Support\Number;
|
||||||
use JaOcero\RadioDeck\Forms\Components\RadioDeck;
|
use JaOcero\RadioDeck\Forms\Components\RadioDeck;
|
||||||
|
|
||||||
|
@ -89,6 +91,13 @@ class BackupResource extends Resource
|
||||||
//
|
//
|
||||||
])
|
])
|
||||||
->actions([
|
->actions([
|
||||||
|
Tables\Actions\Action::make('download')
|
||||||
|
->icon('heroicon-o-arrow-down-tray')
|
||||||
|
->action(function (Backup $backup) {
|
||||||
|
$url = Storage::disk('backups')
|
||||||
|
->temporaryUrl($backup->filepath, Carbon::now()->addMinutes(5));
|
||||||
|
return redirect($url);
|
||||||
|
}),
|
||||||
Tables\Actions\ViewAction::make(),
|
Tables\Actions\ViewAction::make(),
|
||||||
])
|
])
|
||||||
->defaultSort('id', 'desc')
|
->defaultSort('id', 'desc')
|
||||||
|
|
25
web/app/Http/Controllers/BackupDownloadController.php
Normal file
25
web/app/Http/Controllers/BackupDownloadController.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\URL;
|
||||||
|
|
||||||
|
class BackupDownloadController extends Controller
|
||||||
|
{
|
||||||
|
public function download(Request $request)
|
||||||
|
{
|
||||||
|
if (!URL::signatureHasNotExpired($request)) {
|
||||||
|
return response('The URL has expired.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!URL::hasCorrectSignature($request)) {
|
||||||
|
return response('Invalid URL provided');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Storage::disk('backups')->download($request->get('path'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ use Filament\Facades\Filament;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\URL;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use Livewire\Livewire;
|
use Livewire\Livewire;
|
||||||
|
|
||||||
|
@ -27,6 +29,15 @@ class AppServiceProvider extends ServiceProvider
|
||||||
*/
|
*/
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
|
// This allows us to generate a temporary url for backups downloading
|
||||||
|
Storage::disk('backups')->buildTemporaryUrlsUsing(function ($path, $expiration, $options) {
|
||||||
|
return URL::temporarySignedRoute(
|
||||||
|
'backup.download',
|
||||||
|
$expiration,
|
||||||
|
array_merge($options, ['path' => $path])
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// Register Phyre Icons set
|
// Register Phyre Icons set
|
||||||
$this->callAfterResolving(Factory::class, function (Factory $factory) {
|
$this->callAfterResolving(Factory::class, function (Factory $factory) {
|
||||||
$factory->add('phyre', [
|
$factory->add('phyre', [
|
||||||
|
|
|
@ -44,6 +44,12 @@ return [
|
||||||
'throw' => false,
|
'throw' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'backups' => [
|
||||||
|
'driver' => 'local',
|
||||||
|
'root' => storage_path('app/backups'),
|
||||||
|
'throw' => false,
|
||||||
|
],
|
||||||
|
|
||||||
's3' => [
|
's3' => [
|
||||||
'driver' => 's3',
|
'driver' => 's3',
|
||||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||||
|
|
|
@ -28,3 +28,6 @@ if (!file_exists(storage_path('installed'))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Route::get('/installer', \App\Livewire\Installer::class);
|
Route::get('/installer', \App\Livewire\Installer::class);
|
||||||
|
|
||||||
|
Route::get('backup/download', [\App\Http\Controllers\BackupDownloadController::class, 'download'])
|
||||||
|
->name('backup.download');
|
||||||
|
|
Loading…
Reference in a new issue