1 | <?php |
||
22 | class AwsS3Resolver implements ResolverInterface |
||
23 | { |
||
24 | use LoggerAwareTrait; |
||
25 | |||
26 | /** |
||
27 | * @var S3Client |
||
28 | */ |
||
29 | protected $storage; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $bucket; |
||
35 | |||
36 | /** |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $acl; |
||
40 | |||
41 | /** |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $getOptions; |
||
45 | |||
46 | /** |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $putOptions; |
||
50 | |||
51 | /** |
||
52 | * @var array |
||
53 | */ |
||
54 | protected $delOptions; |
||
55 | |||
56 | /** |
||
57 | * @var LoggerInterface |
||
58 | */ |
||
59 | protected $logger; |
||
60 | |||
61 | /** |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $cachePrefix; |
||
65 | |||
66 | /** |
||
67 | * @param S3Client $storage The Amazon S3 storage API. It's required to know authentication information |
||
68 | * @param string $bucket The bucket name to operate on |
||
69 | * @param string|null $acl The ACL to use when storing new objects. Default: owner read/write, public read |
||
70 | * @param array $getOptions A list of options to be passed when retrieving an object url from Amazon S3 |
||
71 | * @param array $putOptions A list of options to be passed when saving an object to Amazon S3 |
||
72 | * @param array $delOptions A list of options to be passed when removing an object from Amazon S3 |
||
73 | * @param string|null $cachePrefix A cache prefix string |
||
74 | */ |
||
75 | public function __construct( |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | public function isStored(string $path, string $filter): bool |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function resolve(string $path, string $filter): string |
||
108 | |||
109 | /** |
||
110 | * {@inheritdoc} |
||
111 | */ |
||
112 | public function store(FileInterface $file, string $path, string $filter): void |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | public function remove(array $paths, array $filters): void |
||
132 | |||
133 | /** |
||
134 | * Returns the object path within the bucket. |
||
135 | * |
||
136 | * @param string $path The base path of the resource |
||
137 | * @param string $filter The name of the imagine filter in effect |
||
138 | * |
||
139 | * @return string The path of the object on S3 |
||
140 | */ |
||
141 | protected function getObjectPath($path, $filter) |
||
149 | |||
150 | /** |
||
151 | * Returns the URL for an object saved on Amazon S3. |
||
152 | * |
||
153 | * @param string $path |
||
154 | * |
||
155 | * @return string |
||
156 | */ |
||
157 | protected function getObjectUrl($path) |
||
168 | |||
169 | /** |
||
170 | * @param array $filters |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | protected function getObjectSearchFilters(array $filters) |
||
183 | |||
184 | /** |
||
185 | * Checks whether an object exists. |
||
186 | * |
||
187 | * @param string $objectPath |
||
188 | * |
||
189 | * @return bool |
||
190 | */ |
||
191 | protected function objectExists($objectPath) |
||
195 | |||
196 | /** |
||
197 | * @param string $path |
||
198 | * @param FileInterface $file |
||
199 | * |
||
200 | * @throws S3Exception |
||
201 | */ |
||
202 | private function putObjectPath(string $path, FileInterface $file): void |
||
224 | |||
225 | /** |
||
226 | * @param string $object |
||
227 | */ |
||
228 | private function delObjectPath(string $object): void |
||
247 | |||
248 | /** |
||
249 | * @param array $filters |
||
250 | */ |
||
251 | private function delMatchingObjectPaths(array $filters): void |
||
263 | } |
||
264 |