You've already forked symfony-storage
Awesome features (you'll see)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Bluesquare\StorageBundle\Adaptors;
|
||||
|
||||
use Aws\S3\S3Client;
|
||||
use Bluesquare\StorageBundle\Exceptions\InvalidStorageConfiguration;
|
||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
|
||||
/**
|
||||
@@ -10,7 +11,7 @@ use Symfony\Component\Config\Definition\Exception\Exception;
|
||||
* Usage: $storage = new S3Storage('my_storage_name', $config);
|
||||
* @author Maxime Renou
|
||||
*/
|
||||
class S3Storage
|
||||
class S3Storage implements StorageAdaptor
|
||||
{
|
||||
const MODE_PRIVATE = 'private';
|
||||
const MODE_PUBLIC = 'public-read';
|
||||
@@ -22,7 +23,7 @@ class S3Storage
|
||||
public function __construct ($storage_name, $config)
|
||||
{
|
||||
if (!($this->configIsNormed($config)))
|
||||
throw new Exception("Error from config file :(");
|
||||
throw new InvalidStorageConfiguration("Invalid $storage_name storage configuration");
|
||||
|
||||
$this->config = $config;
|
||||
$this->bucket = $config['bucket'];
|
||||
@@ -38,6 +39,12 @@ class S3Storage
|
||||
]);
|
||||
}
|
||||
|
||||
public function mode($name)
|
||||
{
|
||||
if ($name == 'public') return self::MODE_PUBLIC;
|
||||
return self::MODE_PRIVATE;
|
||||
}
|
||||
|
||||
private function configIsNormed($config)
|
||||
{
|
||||
return (
|
||||
|
||||
13
StorageBundle/Adaptors/StorageAdaptor.php
Normal file
13
StorageBundle/Adaptors/StorageAdaptor.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Bluesquare\StorageBundle\Adaptors;
|
||||
|
||||
interface StorageAdaptor
|
||||
{
|
||||
public function index();
|
||||
public function mode($name);
|
||||
public function store($source_path, $target_path);
|
||||
public function retrieve($distant_path, $local_path);
|
||||
public function stream($distant_path, $target_stream);
|
||||
public function delete($distant_path);
|
||||
}
|
||||
Reference in New Issue
Block a user