/** * Constructor * * @param $accessKeyId * @param $secretAccessKey * @param $bucket * @param bool $dateFolderStructure If true, will append Y/m/d to the key * @param bool $cdnDomain * * @internal param $config */ public function __construct($accessKeyId, $secretAccessKey, $bucket, $dateFolderStructure = false, $cdnDomain = false) { $bridge = Storage::getConfig()->get('Bridges.AmazonS3', '\\Webiny\\Component\\Amazon\\S3'); $this->s3Client = new $bridge($accessKeyId, $secretAccessKey); $this->bucket = $bucket; $this->dateFolderStructure = $dateFolderStructure; $this->cdnDomain = $cdnDomain; }
public function __construct($accessKeyId, $secretAccessKey) { $bridgeClass = Storage::getConfig()->get('Bridges.AmazonS3', '\\Webiny\\Component\\Amazon\\S3'); $mock = $this->getMockBuilder($bridgeClass)->disableOriginalConstructor()->getMock(); $mock->expects($this->any())->method('getObject')->willReturn(['Body' => 'Test contents']); $mock->expects($this->any())->method('deleteObject')->willReturn([]); $mock->expects($this->any())->method('putObject')->willReturn([]); $mock->expects($this->any())->method('doesObjectExist')->will($this->onConsecutiveCalls(true, false)); $this->instance = $mock; }
/** * Constructor * * @param array|ArrayObject $config * * @throws StorageException */ public function __construct($config) { if (is_array($config)) { $config = new ArrayObject($config); } if (!$config instanceof ArrayObject) { throw new StorageException('Storage driver config must be an array or ArrayObject!'); } $bridge = Storage::getConfig()->get('Bridges.AmazonS3', '\\Webiny\\Component\\Amazon\\S3'); $accessKeyId = $config->key('AccessKeyId'); $secretAccessKey = $config->key('SecretAccessKey'); $region = $config->key('Region'); $endpoint = $config->key('Endpoint'); $this->s3Client = new $bridge($accessKeyId, $secretAccessKey, $region, $endpoint); $this->bucket = $config->key('Bucket'); $this->cdnDomain = $config->key('CdnDomain'); $this->meta = $config->key('Meta'); }
public function testConfigServices() { $this->assertFalse(Storage::getConfig()->get('Bridges.FakeBridge', false)); }
public function testConfigServices() { $this->assertSame('%StorageClass%', Storage::getConfig()->get('Services.LocalStorage.Class')); $this->assertFalse(Storage::getConfig()->get('Bridges.FakeBridge', false)); }