1 | <?php |
||
19 | class AwsS3Resolver implements ResolverInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var S3Client |
||
23 | */ |
||
24 | protected $storage; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $bucket; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | protected $acl; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $getOptions; |
||
40 | |||
41 | /** |
||
42 | * Object options added to PUT requests. |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $putOptions; |
||
47 | |||
48 | /** |
||
49 | * @var LoggerInterface |
||
50 | */ |
||
51 | protected $logger; |
||
52 | |||
53 | /** |
||
54 | * @var string |
||
55 | */ |
||
56 | protected $cachePrefix; |
||
57 | |||
58 | /** |
||
59 | * Constructs a cache resolver storing images on Amazon S3. |
||
60 | * |
||
61 | * @param S3Client $storage The Amazon S3 storage API. It's required to know authentication information |
||
62 | * @param string $bucket The bucket name to operate on |
||
63 | * @param string $acl The ACL to use when storing new objects. Default: owner read/write, public read |
||
64 | * @param array $getOptions A list of options to be passed when retrieving the object url from Amazon S3 |
||
65 | * @param array $putOptions A list of options to be passed when saving the object to Amazon S3 |
||
66 | */ |
||
67 | public function __construct(S3Client $storage, $bucket, $acl = 'public-read', array $getOptions = [], $putOptions = []) |
||
75 | |||
76 | public function setLogger(LoggerInterface $logger) |
||
80 | |||
81 | /** |
||
82 | * @param string $cachePrefix |
||
83 | */ |
||
84 | public function setCachePrefix($cachePrefix) |
||
88 | |||
89 | /** |
||
90 | * {@inheritdoc} |
||
91 | */ |
||
92 | public function isStored($path, $filter) |
||
96 | |||
97 | /** |
||
98 | * {@inheritdoc} |
||
99 | */ |
||
100 | public function resolve($path, $filter) |
||
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | public function store(BinaryInterface $binary, $path, $filter) |
||
136 | |||
137 | /** |
||
138 | * {@inheritdoc} |
||
139 | */ |
||
140 | public function remove(array $paths, array $filters) |
||
186 | |||
187 | /** |
||
188 | * Sets a single option to be passed when retrieving an objects URL. |
||
189 | * |
||
190 | * If the option is already set, it will be overwritten. |
||
191 | * |
||
192 | * @see \Aws\S3\S3Client::getObjectUrl() for available options |
||
193 | * |
||
194 | * @param string $key The name of the option |
||
195 | * @param mixed $value The value to be set |
||
196 | * |
||
197 | * @return $this |
||
198 | */ |
||
199 | public function setGetOption($key, $value) |
||
205 | |||
206 | /** |
||
207 | * Sets a single option to be passed when saving an object. |
||
208 | * |
||
209 | * If the option is already set, it will be overwritten. |
||
210 | * |
||
211 | * @see \Aws\S3\S3Client::putObject() for available options |
||
212 | * |
||
213 | * @param string $key The name of the option |
||
214 | * @param mixed $value The value to be set |
||
215 | * |
||
216 | * @return $this |
||
217 | */ |
||
218 | public function setPutOption($key, $value) |
||
224 | |||
225 | /** |
||
226 | * Returns the object path within the bucket. |
||
227 | * |
||
228 | * @param string $path The base path of the resource |
||
229 | * @param string $filter The name of the imagine filter in effect |
||
230 | * |
||
231 | * @return string The path of the object on S3 |
||
232 | */ |
||
233 | protected function getObjectPath($path, $filter) |
||
241 | |||
242 | /** |
||
243 | * Returns the URL for an object saved on Amazon S3. |
||
244 | * |
||
245 | * @param string $path |
||
246 | * |
||
247 | * @return string |
||
248 | */ |
||
249 | protected function getObjectUrl($path) |
||
253 | |||
254 | /** |
||
255 | * Checks whether an object exists. |
||
256 | * |
||
257 | * @param string $objectPath |
||
258 | * |
||
259 | * @return bool |
||
260 | */ |
||
261 | protected function objectExists($objectPath) |
||
265 | |||
266 | /** |
||
267 | * @param mixed $message |
||
268 | */ |
||
269 | protected function logError($message, array $context = []) |
||
275 | } |
||
276 |