Skip to content

Instantly share code, notes, and snippets.

@cosmomathieu
Last active April 8, 2023 02:58
Show Gist options
  • Save cosmomathieu/529df695fc452c42ce0f9e8271e1e97e to your computer and use it in GitHub Desktop.
Save cosmomathieu/529df695fc452c42ce0f9e8271e1e97e to your computer and use it in GitHub Desktop.
Using FlySystem with Digital Oceans Spaces
<?php
class FileManager
{
const USER_FOLDER = siteData()->userFolder;
protected $adapter;
public function __construct($adapter)
{
$this->adapter = $adapter;
}
}
$fileManager = new FileManager(new App\Libraries\FileManager\Adapters\DOSpaces());
$fileManager->init();
<?php
use Aws\S3\S3Client;
use League\Flysystem\AwsS3v3\AwsS3Adapter;
use League\Flysystem\Filesystem;
include __DIR__.'/vendor/autoload.php';
$client = new S3Client([
'endpoint' => 'https://nyc3.digitaloceanspaces.com',
'version' => 'latest',
'credentials' => [
'key' => 'KEY',
'secret' => 'SECRET'
],
'region' => 'nyc3',
]);
$adapter = new AwsS3Adapter($client, 'flysystem-test');
$filesystem = new Filesystem($adapter);
print_r($filesystem->listContents());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment