1 | <?php |
||
28 | class AmazonServer extends AbstractServer |
||
29 | { |
||
30 | /** |
||
31 | * @invisible |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $options = [ |
||
35 | 'server' => 'https://s3.amazonaws.com', |
||
36 | 'timeout' => 0, |
||
37 | 'accessKey' => '', |
||
38 | 'secretKey' => '' |
||
39 | ]; |
||
40 | |||
41 | /** |
||
42 | * @invisible |
||
43 | * @var ClientInterface |
||
44 | */ |
||
45 | protected $client = null; |
||
46 | |||
47 | /** |
||
48 | * @param array $options |
||
49 | * @param FilesInterface|null $files |
||
50 | * @param ClientInterface|null $client |
||
51 | */ |
||
52 | public function __construct( |
||
62 | |||
63 | /** |
||
64 | * @param ClientInterface $client |
||
65 | * |
||
66 | * @return self |
||
67 | */ |
||
68 | public function setClient(ClientInterface $client): AmazonServer |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | * |
||
78 | * @param ResponseInterface $response Reference. |
||
79 | * |
||
80 | * @return bool|ResponseInterface |
||
81 | */ |
||
82 | public function exists( |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | public function size(BucketInterface $bucket, string $name) |
||
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | public function put(BucketInterface $bucket, string $name, $source): bool |
||
147 | |||
148 | /** |
||
149 | * {@inheritdoc} |
||
150 | */ |
||
151 | public function allocateStream(BucketInterface $bucket, string $name): StreamInterface |
||
166 | |||
167 | /** |
||
168 | * {@inheritdoc} |
||
169 | */ |
||
170 | public function delete(BucketInterface $bucket, string $name) |
||
178 | |||
179 | /** |
||
180 | * {@inheritdoc} |
||
181 | */ |
||
182 | public function rename(BucketInterface $bucket, string $oldName, string $newName): bool |
||
204 | |||
205 | /** |
||
206 | * {@inheritdoc} |
||
207 | */ |
||
208 | public function copy(BucketInterface $bucket, BucketInterface $destination, string $name): bool |
||
228 | |||
229 | /** |
||
230 | * Create instance of UriInterface based on provided bucket options and storage object name. |
||
231 | * |
||
232 | * @param BucketInterface $bucket |
||
233 | * @param string $name |
||
234 | * |
||
235 | * @return UriInterface |
||
236 | */ |
||
237 | protected function buildUri(BucketInterface $bucket, string $name): UriInterface |
||
243 | |||
244 | /** |
||
245 | * Helper to create configured PSR7 request with set of amazon commands. |
||
246 | * |
||
247 | * @param string $method |
||
248 | * @param BucketInterface $bucket |
||
249 | * @param string $name |
||
250 | * @param array $headers |
||
251 | * @param array $commands Amazon commands associated with values. |
||
252 | * |
||
253 | * @return RequestInterface |
||
254 | */ |
||
255 | protected function buildRequest( |
||
275 | |||
276 | /** |
||
277 | * Generate request headers based on provided set of amazon commands. |
||
278 | * |
||
279 | * @param array $commands |
||
280 | * |
||
281 | * @return array |
||
282 | */ |
||
283 | private function packCommands(array $commands): array |
||
292 | |||
293 | /** |
||
294 | * Sign amazon request. |
||
295 | * |
||
296 | * @param RequestInterface $request |
||
297 | * @param array $packedCommands Headers generated based on request commands, see |
||
298 | * packCommands() method for more information. |
||
299 | * |
||
300 | * @return RequestInterface |
||
301 | */ |
||
302 | private function signRequest( |
||
334 | |||
335 | /** |
||
336 | * Generate object headers. |
||
337 | * |
||
338 | * @param BucketInterface $bucket |
||
339 | * @param string $name |
||
340 | * @param mixed $source |
||
341 | * |
||
342 | * @return array |
||
343 | */ |
||
344 | private function createHeaders(BucketInterface $bucket, string $name, $source): array |
||
367 | } |