Blame view

vendor/mihaildev/yii2-elfinder/S3Path.php 1.34 KB
ad2e91f7   Mihail   move multyparser ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  <?php
  /**
   * Date: 12.05.15
   * Time: 17:29
   *
   * This file is part of the MihailDev project.
   *
   * (c) MihailDev project <http://github.com/mihaildev/>
   *
   * For the full copyright and license information, please view the LICENSE
   * file that was distributed with this source code.
  */
  
  namespace mihaildev\elfinder;
  
  /**
   * Class S3Path
   *
   */
  class S3Path extends BasePath{
  	public $driver = 'S3';
  	public $accessKey = '';
  	public $secretKey = '';
  	public $bucket = '';
  	public $region = '';
  	public $path = '';
  
  	public function getRoot(){
  		$options = parent::getRoot();
  		$options['separator'] = '/';
  
  		$options['s3']= [
  			'key' => $this->accessKey,
  			'secret' => $this->secretKey,
  			'region' => $this->region,
  			'scheme' => 'http',
  			'ssl.certificate_authority' => false
  		];
  
  		$options['bucket'] = $this->bucket;
  
  		if(empty($this->path)) {
  			$options['path'] = './';
  			$options['URL'] = 'http://' . $this->bucket . '.s3-website-' . $this->region . '.amazonaws.com/';
  		}else{
  			$this->path = trim($this->path, '/');
  			$options['path'] = $this->path;
  			$options['URL'] = 'http://' . $this->bucket . '.s3-website-' . $this->region . '.amazonaws.com/'.$this->path;
  		}
  
  		$options['acl'] = 'public';
  
  		if($options['defaults']['read'])
  			$options['acl'] .= '-read';
  
  		if($options['defaults']['write'])
  			$options['acl'] .= '-write';
  		return $options;
  	}
  }