nikkiii/flysystem-acd

Flysystem Interface for Amazon Cloud Drive

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

This package is not auto-updated.

Last update: 2024-11-18 07:33:29 UTC


README

This is an Amazon Cloud Drive adapter for Flysystem.

Installation

Composer is the best way, as with all of Flysystem!

composer require nikkiii/flysystem-acd

Usage

This is a bit tougher, since there's no automated way to authenticate amazon cloud drive. You'll need a client id and secret from Cloud Drive's API, and to manually pass the url into the authorize method on the CloudDrive account object.

Initial setup would be something like this:

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

Repeat usage would be simpler (no authentication 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