traineratwot/yandex-disk-flysystem

Yandex Disk REST API 的 flysystem 适配器。

1.0.5 2022-04-29 09:14 UTC

This package is auto-updated.

Last update: 2024-09-29 06:09:06 UTC


README

开发中

访问 https://oauth.yandex.ru,创建应用程序并获取调试 OAuth 令牌。

访问 https://oauth.yandex.com 并创建应用程序。获取您的 OAuth 令牌。

安装(Installation)

$ composer require arhitector/yandex-disk-flysystem dev-master

使用(Usage)

您可以使用应用程序文件夹作为根路径,为此请使用 Arhitector\Yandex\Disk\Adapter::PREFIX_APP(值 "app:/")作为第二个参数 $prefix。默认使用 Arhitector\Yandex\Disk\Adapter::PREFIX_FULL,相当于 "disk:/" - 访问整个磁盘。

public __construct(Disk $client [, $prefix = 'disk:/'])

$client 是已安装 OAuth-令牌的 Arhitector\Yandex\Disk 对象实例。

$prefix 要使用应用程序文件夹,请传递 Arhitector\Yandex\Disk\Adapter::PREFIX_APP

Arhitector\Yandex\Disk\Adapter::PREFIX_FULL 访问整个磁盘(默认)。

Arhitector\Yandex\Disk\Adapter::PREFIX_APP 了解更多信息 https://tech.yandex.com/disk/api/concepts/app-folders-docpage/

// set a token before creation of the adapter
$client = new Arhitector\Yandex\Disk([string $accessToken]);

// or
$client->setAccessToken(string $accessToken);

// create adapter
$adapter = new traineratwot\Yandex\Disk\Adapter\Flysystem($client);

// or with app folder
$adapter = new traineratwot\Yandex\Disk\Adapter\Flysystem($client, traineratwot\Yandex\Disk\Adapter\Flysystem::PREFIX_APP);

// create Filesystem
$filesystem = new League\Flysystem\Filesystem($adapter);

// and use
$contents = $filesystem->listContents();

var_dump($contents);

注册事件监听器

$filesystem->write('path', 'contents', [
    'events' => [
        'event-name 1' => 'listener', /* function, etc. */
        'event-name 2' => 'other listener'
    ]
]);

注册多个监听器

$filesystem->write('path', 'contents', [
    'events' => [
        'event-name' => [
            'listener 1' /* function, etc. */,
            'listener 2' /* function, etc. */,
            'listener 3' /* function, etc. */
        ]
    ]
]);

许可证(License)

MIT 许可证(MIT)