Skip to content

YandexDisk Storage filesystem for Flysystem

Notifications You must be signed in to change notification settings

Dakword/yandexdisk-storage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YandexDisk Storage filesystem for Flysystem

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');

Links

About

YandexDisk Storage filesystem for Flysystem

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages