arquivei/flysystem-php
arquivei/flysystems-php
Google Cloud Storage and Amazon S3 adapters for php.
This project is based-on League\Flysystem [http://flysystem.thephpleague.com/docs/].
Version Compatibility
| Releases | Laravel |
|---|---|
| 4.x | ^8.0 |
| 3.x | ^7.15 |
| 2.x | ^6.0 |
| 1.x | ^5.7 |
Installation
composer require arquivei/flysystem-php:1.0.0
How to use
Using with Google Cloud Storage
require_once ('vendor/autoload.php');
$gcsStorage = new \Arquivei\Flysystems\ArquiveiStorage\Adapters\GoogleCloudStorage(
new \Google\Cloud\Storage\StorageClient([
'projectId' => 'my-project',
'keyFilePath' => './auth.json'
])
);
$gcsStorage->setBucket('my-bucket');
$gcsStorage->putObject('data', '2019/key/');
Using with Amazon Aws S3
$awsStorage = new \Arquivei\Flysystems\ArquiveiStorage\Adapters\AmazonAwsStorage(
new \Aws\S3\S3Client([
'key' => 'my-key',
'secret' => 'my-secret',
'region' => 'my-region',
'version' => 'my-version'
])
);
$awsStorage->setBucket('my-bucket');
$awsStorage->putObject('data', '2019/key/');
Using with Laravel
The first step you need to do is register the service provider in app.php
'providers' => [
Arquivei\Flysystems\GoogleCloudStorage\GoogleCloudStorageProvider::class,
]
Then, create the config in filesystem.php
'gcs' => [
'driver' => 'gcs',
'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'your-project-id'),
'key_file' => env('GOOGLE_CLOUD_KEY_FILE', null),
'bucket' => env('GOOGLE_CLOUD_STORAGE_BUCKET', 'your-bucket'),
'path_prefix' => env('GOOGLE_CLOUD_STORAGE_PATH_PREFIX', null),
'storage_api_uri' => env('GOOGLE_CtestingLOUD_STORAGE_API_URI', null),
'visibility' => env('GOOGLE_CLOUD_STORAGE_API_URI', 'private'),
],
You must need an adapter like:
class IlluminateStorageAdapter
{
private $storage;
public function __construct()
{
$client = \Storage::cloud()
->getDriver()
->getAdapter()
->getClient();
if ($client instanceof StorageClient) {
$this->storage = new GoogleCloudStorage($client);
}
if ($client instanceof S3Client) {
$this->storage = new AmazonAwsStorage($client);
}
if((!$client instanceof StorageClient) && (!$client instanceof S3Client)){
throw new StorageNotFoundException();
}
}
public function setBucket(String $bucket) : IlluminateStorageAdapter
{
$this->storage->setBucket($bucket);
return $this;
}
public function setBasePath(String $basePath) : IlluminateStorageAdapter
{
$this->storage->setBasePath($basePath);
return $this;
}
public function getObjectAsync(array $keys): array
{
return $this->storage->getObjectAsync($keys);
}
public function putObject(String $data, String $key, String $acl = "private") : String
{
return $this->storage->putObject($data, $key, $acl);
}
}
Maintainers
André Lázari andre.lazari@arquivei.com.br
Thales Castro thales.mendes@arquivei.com.br
Related Packages
mmieluch/laravel-vfs-provider
A Laravel service provider for Flysystem's wrapper around PHP-VFS.
18,167
4
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 5.0.1 | ^8.0 | ^9.0 | MIT | |
| 5.0.0 | ^8.0 | ^9.0 | MIT | |
| 4.1.1 | ^8.0 | ^8.0 | MIT | |
| 4.1.0 | ^8.0 | ^8.0 | MIT | |
| 4.0.0 | ^8.0 | ^8.0 | MIT | |
| 3.0.0 | ^7.1.3 | ^7.0 | MIT | |
| 2.5.1 | ^7.1.3 | ^6.0 | MIT | |
| 2.5.0 | ^7.1.3 | ^6.0 | MIT | |
| 2.4.2 | ^7.1.3 | ^6.0 | MIT | |
| 2.4.1 | ^7.1.3 | ^6.0 | MIT | |
| 2.4.0 | ^7.1.3 | ^6.0 | MIT | |
| 2.3.0 | ^7.1.3 | ^6.0 | MIT | |
| 2.2.0 | ^7.1.3 | ^6.0 | MIT | |
| 2.1.0 | ^7.1.3 | ^6.0 | MIT | |
| 2.0.0 | ^7.1.3 | ^6.0 | MIT | |
| 1.6.1 | ^7.1.3 | ^5.5 | MIT | |
| 1.6.0 | ^7.1.3 | ^5.5 | MIT | |
| 1.5.0 | ^7.1.3 | ^5.5 | MIT | |
| 1.4.0 | ^7.1.3 | ^5.5 | MIT | |
| 1.3.0 | ^7.1.3 | ^5.5 | MIT | |
| 1.2.0 | ^7.1.3 | ^5.5 | MIT | |
| 1.1.1 | ^7.1.3 | ^5.5 | MIT | |
| 1.1.0 | ^7.1.3 | ^5.5 | MIT | |
| 1.0.0 | ^7.1.3 | ^5.5 | MIT |