nikkiii/flysystem-acd

Amazon Cloud Drive 的 Flysystem 接口

v0.0.1 2016-11-14 16:57 UTC

This package is not auto-updated.

Last update: 2024-09-23 06:48:35 UTC


README

这是一个 Amazon Cloud Drive 的适配器,用于 Flysystem

安装

使用 Composer 是最佳方式,正如 Flysystem 的所有操作一样!

composer require nikkiii/flysystem-acd

使用方法

这有点困难,因为没有自动认证 Amazon Cloud Drive 的方法。您需要从 Cloud Drive 的 API 获取客户端 ID 和密钥,并手动将 URL 传递到 CloudDrive 账户对象的 authorize 方法。

初始设置可能如下所示

use CloudDrive\Cache\SQLite;
use CloudDrive\CloudDrive;
use CloudDrive\Node;
use League\Flysystem\Filesystem;
use Nikkii\Flysystem\ACD\AmazonCloudDrive;

$cache = new SQLite('email', './cache');

$drive = new CloudDrive('email', 'client id', 'secret', $cache);

$response = $drive->getAccount()->authorize();

if (!$response['success']) {
	print_r($response); // Get the URL from here
}

// Input the resulting redirected url
$url = readline();

$response = $drive->getAccount()->authorize($url);

// Initialize Node
Node::init($drive->getAccount(), $cache);

// Sync your local cache with the current state of your Cloud Drive.
$drive->getAccount()->sync();

$flysystem = new Filesystem(new AmazonCloudDrive($drive));

// Access flysystem like usual

重复使用会更简单(无需认证 URL)

use CloudDrive\Cache\SQLite;
use CloudDrive\CloudDrive;
use CloudDrive\Node;
use League\Flysystem\Filesystem;
use Nikkii\Flysystem\ACD\AmazonCloudDrive;

$cache = new SQLite('email', './cache');

$drive = new CloudDrive('email', 'client id', 'secret', $cache);

$response = $drive->getAccount()->authorize();

if (!$response['success']) {
	// Something is wrong
	return;
}

// Initialize Node
Node::init($drive->getAccount(), $cache);

// Sync your local cache with the current state of your Cloud Drive.
$drive->getAccount()->sync();

$flysystem = new Filesystem(new AmazonCloudDrive($drive));

// Access flysystem like usual