@@ -25,80 +25,80 @@ |
||
25 | 25 | use OCP\Files\ObjectStore\IObjectStore; |
26 | 26 | |
27 | 27 | class Azure implements IObjectStore { |
28 | - /** @var string */ |
|
29 | - private $containerName; |
|
30 | - /** @var string */ |
|
31 | - private $accountName; |
|
32 | - /** @var string */ |
|
33 | - private $accountKey; |
|
34 | - /** @var BlobRestProxy|null */ |
|
35 | - private $blobClient = null; |
|
36 | - /** @var string|null */ |
|
37 | - private $endpoint = null; |
|
28 | + /** @var string */ |
|
29 | + private $containerName; |
|
30 | + /** @var string */ |
|
31 | + private $accountName; |
|
32 | + /** @var string */ |
|
33 | + private $accountKey; |
|
34 | + /** @var BlobRestProxy|null */ |
|
35 | + private $blobClient = null; |
|
36 | + /** @var string|null */ |
|
37 | + private $endpoint = null; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param array $parameters |
|
41 | - */ |
|
42 | - public function __construct($parameters) { |
|
43 | - $this->containerName = $parameters['container']; |
|
44 | - $this->accountName = $parameters['account_name']; |
|
45 | - $this->accountKey = $parameters['account_key']; |
|
46 | - if (isset($parameters['endpoint'])) { |
|
47 | - $this->endpoint = $parameters['endpoint']; |
|
48 | - } |
|
49 | - } |
|
39 | + /** |
|
40 | + * @param array $parameters |
|
41 | + */ |
|
42 | + public function __construct($parameters) { |
|
43 | + $this->containerName = $parameters['container']; |
|
44 | + $this->accountName = $parameters['account_name']; |
|
45 | + $this->accountKey = $parameters['account_key']; |
|
46 | + if (isset($parameters['endpoint'])) { |
|
47 | + $this->endpoint = $parameters['endpoint']; |
|
48 | + } |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * @return BlobRestProxy |
|
53 | - */ |
|
54 | - private function getBlobClient() { |
|
55 | - if (!$this->blobClient) { |
|
56 | - $protocol = $this->endpoint ? substr($this->endpoint, 0, strpos($this->endpoint, ':')) : 'https'; |
|
57 | - $connectionString = "DefaultEndpointsProtocol=" . $protocol . ";AccountName=" . $this->accountName . ";AccountKey=" . $this->accountKey; |
|
58 | - if ($this->endpoint) { |
|
59 | - $connectionString .= ';BlobEndpoint=' . $this->endpoint; |
|
60 | - } |
|
61 | - $this->blobClient = BlobRestProxy::createBlobService($connectionString); |
|
62 | - } |
|
63 | - return $this->blobClient; |
|
64 | - } |
|
51 | + /** |
|
52 | + * @return BlobRestProxy |
|
53 | + */ |
|
54 | + private function getBlobClient() { |
|
55 | + if (!$this->blobClient) { |
|
56 | + $protocol = $this->endpoint ? substr($this->endpoint, 0, strpos($this->endpoint, ':')) : 'https'; |
|
57 | + $connectionString = "DefaultEndpointsProtocol=" . $protocol . ";AccountName=" . $this->accountName . ";AccountKey=" . $this->accountKey; |
|
58 | + if ($this->endpoint) { |
|
59 | + $connectionString .= ';BlobEndpoint=' . $this->endpoint; |
|
60 | + } |
|
61 | + $this->blobClient = BlobRestProxy::createBlobService($connectionString); |
|
62 | + } |
|
63 | + return $this->blobClient; |
|
64 | + } |
|
65 | 65 | |
66 | - public function createContainer($name) { |
|
67 | - $this->getBlobClient()->createContainer($name); |
|
68 | - } |
|
66 | + public function createContainer($name) { |
|
67 | + $this->getBlobClient()->createContainer($name); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * @return string the container or bucket name where objects are stored |
|
72 | - */ |
|
73 | - public function getStorageId() { |
|
74 | - return 'azure::blob::' . $this->containerName; |
|
75 | - } |
|
70 | + /** |
|
71 | + * @return string the container or bucket name where objects are stored |
|
72 | + */ |
|
73 | + public function getStorageId() { |
|
74 | + return 'azure::blob::' . $this->containerName; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @param string $urn the unified resource name used to identify the object |
|
79 | - * @return resource stream with the read data |
|
80 | - * @throws \Exception when something goes wrong, message will be logged |
|
81 | - */ |
|
82 | - public function readObject($urn) { |
|
83 | - $blob = $this->getBlobClient()->getBlob($this->containerName, $urn); |
|
84 | - return $blob->getContentStream(); |
|
85 | - } |
|
77 | + /** |
|
78 | + * @param string $urn the unified resource name used to identify the object |
|
79 | + * @return resource stream with the read data |
|
80 | + * @throws \Exception when something goes wrong, message will be logged |
|
81 | + */ |
|
82 | + public function readObject($urn) { |
|
83 | + $blob = $this->getBlobClient()->getBlob($this->containerName, $urn); |
|
84 | + return $blob->getContentStream(); |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @param string $urn the unified resource name used to identify the object |
|
89 | - * @param resource $stream stream with the data to write |
|
90 | - * @throws \Exception when something goes wrong, message will be logged |
|
91 | - */ |
|
92 | - public function writeObject($urn, $stream) { |
|
93 | - $this->getBlobClient()->createBlockBlob($this->containerName, $urn, $stream); |
|
94 | - } |
|
87 | + /** |
|
88 | + * @param string $urn the unified resource name used to identify the object |
|
89 | + * @param resource $stream stream with the data to write |
|
90 | + * @throws \Exception when something goes wrong, message will be logged |
|
91 | + */ |
|
92 | + public function writeObject($urn, $stream) { |
|
93 | + $this->getBlobClient()->createBlockBlob($this->containerName, $urn, $stream); |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @param string $urn the unified resource name used to identify the object |
|
98 | - * @return void |
|
99 | - * @throws \Exception when something goes wrong, message will be logged |
|
100 | - */ |
|
101 | - public function deleteObject($urn) { |
|
102 | - $this->getBlobClient()->deleteBlob($this->containerName, $urn); |
|
103 | - } |
|
96 | + /** |
|
97 | + * @param string $urn the unified resource name used to identify the object |
|
98 | + * @return void |
|
99 | + * @throws \Exception when something goes wrong, message will be logged |
|
100 | + */ |
|
101 | + public function deleteObject($urn) { |
|
102 | + $this->getBlobClient()->deleteBlob($this->containerName, $urn); |
|
103 | + } |
|
104 | 104 | } |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | private function getBlobClient() { |
55 | 55 | if (!$this->blobClient) { |
56 | 56 | $protocol = $this->endpoint ? substr($this->endpoint, 0, strpos($this->endpoint, ':')) : 'https'; |
57 | - $connectionString = "DefaultEndpointsProtocol=" . $protocol . ";AccountName=" . $this->accountName . ";AccountKey=" . $this->accountKey; |
|
57 | + $connectionString = "DefaultEndpointsProtocol=".$protocol.";AccountName=".$this->accountName.";AccountKey=".$this->accountKey; |
|
58 | 58 | if ($this->endpoint) { |
59 | - $connectionString .= ';BlobEndpoint=' . $this->endpoint; |
|
59 | + $connectionString .= ';BlobEndpoint='.$this->endpoint; |
|
60 | 60 | } |
61 | 61 | $this->blobClient = BlobRestProxy::createBlobService($connectionString); |
62 | 62 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return string the container or bucket name where objects are stored |
72 | 72 | */ |
73 | 73 | public function getStorageId() { |
74 | - return 'azure::blob::' . $this->containerName; |
|
74 | + return 'azure::blob::'.$this->containerName; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |