forked from CoderKungfu/php-queue
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmazonS3.php
More file actions
47 lines (40 loc) · 1.26 KB
/
Copy pathAmazonS3.php
File metadata and controls
47 lines (40 loc) · 1.26 KB
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
<?php
namespace PHPQueue\Backend;
use PHPQueue\Backend\Aws\AmazonS3V1;
use PHPQueue\Backend\Aws\AmazonS3V2;
use PHPQueue\Exception\BackendException;
class AmazonS3 extends Proxy
{
protected $options;
public function __construct($options=array())
{
$this->options = $options;
}
/**
* @throws \PHPQueue\Exception\BackendException
* @return \PHPQueue\Backend\Aws\AmazonS3V1|\PHPQueue\Backend\Aws\AmazonS3V2
*/
public function getBackend()
{
if (null === $this->backend) {
if (class_exists('\Aws\S3\S3Client')) { // SDK v2
$this->backend = new AmazonS3V2($this->options);
} elseif (class_exists('\AmazonS3')) { // SDK v1
$this->backend = new AmazonS3V1($this->options);
} else {
throw new BackendException('AWS PHP SDK not found.');
}
}
return $this->backend;
}
/**
* @throws \PHPQueue\Exception\BackendException
*/
public function setBackend($backend)
{
if (!$backend instanceof AmazonS3V1 && !$backend instanceof AmazonS3V2) {
throw new BackendException('Backend must be instance of AmazonS3V1 or AmazonS3V2.');
}
$this->backend = $backend;
}
}