arhitector/yandex-disk-flysystem

Yandex Disk REST API 的 flysystem 适配器。

1.0.2 2018-01-03 14:57 UTC

This package is auto-updated.

Last update: 2024-09-11 14:28:25 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 Arhitector\Yandex\Disk\Adapter\Flysystem($client);

// or with app folder
$adapter = new Arhitector\Yandex\Disk\Adapter\Flysystem($client, Arhitector\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)