mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 13:41:23 +00:00
40 lines
930 B
PHP
40 lines
930 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Filesystem\FilesystemAdapter;
|
|
use Illuminate\Support\Facades\Storage;
|
|
use Illuminate\Support\ServiceProvider;
|
|
use League\Flysystem\Filesystem;
|
|
use Spatie\Dropbox\Client as DropboxClient;
|
|
use Spatie\FlysystemDropbox\DropboxAdapter;
|
|
|
|
class DropboxServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* Register services.
|
|
*/
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Bootstrap services.
|
|
*/
|
|
public function boot(): void
|
|
{
|
|
Storage::extend('dropbox', function ($app, $config) {
|
|
$client = new DropboxClient(
|
|
$config['token']
|
|
);
|
|
|
|
$root = trim($config['root'] ?? '', '/');
|
|
$adapter = new DropboxAdapter($client, $root);
|
|
$flysystem = new Filesystem($adapter);
|
|
|
|
return new FilesystemAdapter($flysystem, $adapter, $config);
|
|
});
|
|
}
|
|
}
|