Skip to content

Commit

Permalink
Merge pull request #8 from imanghafoori1/master
Browse files Browse the repository at this point in the history
Putting tus related stuff in TusServiceProvider
  • Loading branch information
PHPJunior authored Aug 21, 2021
2 parents 23e39ff + 21ce98b commit e48ef13
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 25 deletions.
19 changes: 1 addition & 18 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

use App\Models\Channel\Video;
use App\Observers\VideoObserver;
use App\Services\GoogleDriveAdapter;
use TusPhp\Tus\Server as TusServer;
use App\Listeners\TusEventListener;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;

class AppServiceProvider extends ServiceProvider
{
Expand All @@ -20,19 +15,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function register()
{
$this->app->singleton('tus-server', function ($app) {
Storage::disk('public')->makeDirectory('uploads');

$server = new TusServer('redis');
$server->setApiPath('/tus')->setUploadDir(storage_path('app/public/uploads'));

$listener = app(TusEventListener::class);
$server->event()->addListener('tus-server.upload.complete', [
$listener, 'handleUploadCompleted'
]);

return $server;
});
//
}

/**
Expand Down
22 changes: 16 additions & 6 deletions app/Providers/TusServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@

namespace App\Providers;

use App\Listeners\TusEventListener;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\ServiceProvider;
use TusPhp\Tus\Server as TusServer;

class TusServiceProvider extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register()
{
//
$this->app->singleton('tus-server', function () {
Storage::disk('public')->makeDirectory('uploads');

$server = new TusServer('redis');
$server->setApiPath('/tus')->setUploadDir(storage_path('app/public/uploads'));

$listener = app(TusEventListener::class);
$server->event()->addListener('tus-server.upload.complete', [
$listener, 'handleUploadCompleted'
]);

return $server;
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,

App\Providers\TusServiceProvider::class,
],

/*
Expand Down

0 comments on commit e48ef13

Please sign in to comment.