1 | <?php |
||
17 | class AWSFileService extends AbstractFileService |
||
18 | { |
||
19 | /** @var S3Client $client Aws services user */ |
||
20 | protected $client; |
||
21 | |||
22 | /** @var string $bucket Aws bucket name */ |
||
23 | public $bucket; |
||
24 | |||
25 | /** @var string $accessKey */ |
||
26 | public $accessKey; |
||
27 | |||
28 | /** @var string $secretKey */ |
||
29 | public $secretKey; |
||
30 | |||
31 | /** @var string $bucketURL Url of amazon bucket */ |
||
32 | public $bucketURL; |
||
33 | |||
34 | /** @var string $region Region of amazon S3 service */ |
||
35 | public $region; |
||
36 | |||
37 | /** @var string Signature */ |
||
38 | public $signature = 'v4'; |
||
39 | |||
40 | /** @var int Resource caching age */ |
||
41 | public $maxAge = 1296000; |
||
42 | |||
43 | /** |
||
44 | * @param null $client AWSClient Object |
||
45 | */ |
||
46 | public function __construct($client = null) |
||
51 | |||
52 | /** |
||
53 | * Initialization stage |
||
54 | */ |
||
55 | public function initialize() |
||
67 | |||
68 | /** |
||
69 | * Write data to a specific relative location |
||
70 | * |
||
71 | * @param mixed $data Data to be written |
||
72 | * @param string $filename File name |
||
73 | * @param string $uploadDir Relative file path |
||
74 | * @return string Relative path to created file, false if there were errors |
||
75 | */ |
||
76 | public function write($data, $filename = '', $uploadDir = '') |
||
90 | |||
91 | /** |
||
92 | * Check existing current file in current file system |
||
93 | * @param $url string Url |
||
94 | * @return boolean File exists or not |
||
95 | */ |
||
96 | public function exists($url) |
||
102 | |||
103 | /** |
||
104 | * Read the file from current file system |
||
105 | * @param $filePath string Full path to file |
||
106 | * @param $filename string File name |
||
107 | * @return string File data |
||
108 | */ |
||
109 | public function read($filePath, $filename = null) |
||
113 | |||
114 | /** |
||
115 | * Delete file from current file system |
||
116 | * @param $filePath string File for deleting |
||
117 | * @return mixed |
||
118 | */ |
||
119 | public function delete($filePath) |
||
126 | |||
127 | /** |
||
128 | * Get file extension in current file system |
||
129 | * @param $filePath string Path |
||
130 | * @return string false if extension not found, otherwise file extension |
||
131 | */ |
||
132 | public function extension($filePath) |
||
144 | |||
145 | /** |
||
146 | * Define if $filePath is directory |
||
147 | * @param string $filePath Path |
||
148 | * @return boolean Is $path a directory or not |
||
149 | */ |
||
150 | public function isDir($filePath) |
||
158 | |||
159 | /** |
||
160 | * Get recursive $path listing collection |
||
161 | * @param string $path Path for listing contents |
||
162 | * @param array $restrict Collection of restricted paths |
||
163 | * @param array $result Collection of restricted paths |
||
164 | * @return array $result Resulting collection used in recursion |
||
165 | */ |
||
166 | public function dir($path, $restrict = array(), & $result = array()) |
||
187 | |||
188 | /** |
||
189 | * Define if $objectKey is directory |
||
190 | * @param $objectKey Object Key |
||
191 | * @return bool Is $objectKey a directory or not |
||
192 | */ |
||
193 | private function isKeyDir($objectKey) |
||
202 | |||
203 | /** |
||
204 | * Create catalog in selected location |
||
205 | * @param string $path Path for new catalog |
||
206 | * @return boolean Result of catalog creating |
||
207 | */ |
||
208 | public function mkDir($path) |
||
213 | } |
||
214 |