dakword / yandexdisk-storage
YandexDisk Storage filesystem for Flysystem
1.3.0
2024-08-30 20:02 UTC
Requires
- php: ^8.1
- arhitector/yandex: 2.3.0
- guzzlehttp/psr7: ^2.7
- league/flysystem: ^3.8
- php-http/message-factory: ^1.1
Requires (Dev)
- orchestra/testbench: ^v8.26.0
- phpunit/phpunit: ^10.5.30
README
Installation
composer require dakword/yandexdisk-storage
Usage
$config = [ // option => default 'visibility' => 'private', // 'public', 'private' 'retain_visibility' => true, 'checksum_algo' => 'md5', // 'md5', 'sha256' ]; $client = new Arhitector\Yandex\Disk('oauth-token'); $adapter = new YandexDiskStorageAdapter($client, $prefix = '/', $config); $yandexDiskStorage = new League\Flysystem\Filesystem($adapter); try { $content = $yandexDiskStorage->read('images/file.jpg'); } catch (FilesystemException | UnableToReadFile $exception) { // handle the error }
Laravel Integration
Dakword\YandexDiskStorage\YandexDiskServiceProvider::class // config/filesystems.php 'yandex' => [ 'driver' => 'yandex-disk', 'token' => env('YANDEX_DISK_OAUTH_TOKEN'), 'prefix' => env('YANDEX_DISK_BASE_PATH', '/'), // option => default 'visibility' => 'private', // 'public', 'private' 'retain_visibility' => true, 'checksum_algo' => 'md5', // 'md5', 'sha256' ], // Usage // -------------------------------------- $yandexDiskStorage = Storage::disk('yandex'); // create a file $yandexDiskStorage->put('images/file.jpg', $imageContents); // check exists $exists = $yandexDiskStorage->exists('images/file.jpg');