This commit is contained in:
Cyprian Beauvois 2019-02-20 12:36:07 +01:00
parent 405d854c01
commit fb171e0655
2 changed files with 12 additions and 32 deletions

View File

@ -25,6 +25,8 @@ class S3Storage
$this->config = $config; $this->config = $config;
$this->bucket = $config['bucket']; $this->bucket = $config['bucket'];
dump($this); die;
$this->client = new S3Client([ $this->client = new S3Client([
'version' => isset($config['version']) ? $config['version'] : 'latest', 'version' => isset($config['version']) ? $config['version'] : 'latest',
'region' => $config['region'], 'region' => $config['region'],

View File

@ -3,6 +3,7 @@
namespace Bluesquare\StorageBundle; namespace Bluesquare\StorageBundle;
use Aws\S3\S3Client; use Aws\S3\S3Client;
use Bluesquare\StorageBundle\Adaptors\S3Storage;
/** /**
* Interface de manipulation des stockages préconfigurés * Interface de manipulation des stockages préconfigurés
@ -10,46 +11,23 @@ use Aws\S3\S3Client;
*/ */
class Storage class Storage
{ {
private $user_config = []; private $config_storage = [];
public function __construct(array $user_config = []) public function __construct(array $user_config = [])
{ {
$this->user_config = $user_config; $this->config_storage = $user_config;
} }
public function get($storage_name) public function get($storage_name)
{ {
// TODO: on récupère les infos sur ce storage dans la config utilisateur (config/bluesquare/storage.yaml) if (array_key_exists($storage_name, $this->config_storage))
// La clef pour la configuration d'un storage devrait être : "storage.{storage_name}" {
$config = $this->config_storage[$storage_name];
// dump($this); die; if ($config['type'] == 's3')
// Si storage.{storage_name}.type == 's3' alors : return new S3Storage($storage_name, $config);
// return new S3Storage($storage_name, $config); // $config c'est le contenu de storage.{storage_name} sous forme de tableau }
// Sinon : return null;
return null; // (on ajoutera d'autres types de stockage plus tard, dont le stockage de fichier sur le serveur actuel)
} }
} }
//storage:
//photos:
// type: s3
// bucket: bluesquare.public
// region: nl-ams
// endpoint: 'https://s3.nl-ams.scw.cloud'
// credentials:
// key: '%env(MYSUPERSECRETAWSKEY)%'
// secret: '%env(MYSUPERSECRETAWSSECRET)%'
// version: lastest # optionnel
// path: '/photos' # optionnel
//
// files:
// type: s3
// bucket: bluesquare.private
// region: nl-ams
// endpoint: 'https://s3.nl-ams.scw.cloud'
// credentials:
// key: '%env(MYSUPERSECRETAWSKEY)%'
// secret: '%env(MYSUPERSECRETAWSSECRET)%'
//
// ...