-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAzureBlobFilesystem.php
42 lines (35 loc) · 997 Bytes
/
AzureBlobFilesystem.php
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
<?php
namespace app\adapters;
use BackupManager\Filesystems\Filesystem;
use League\Flysystem\Filesystem as Flysystem;
use League\Flysystem\Azure\AzureAdapter;
use MicrosoftAzure\Storage\Common\ServicesBuilder;
/**
* Created by prabath.
* Date: 11/13/17
* Time: 15:11
*/
class AzureBlobFilesystem implements Filesystem
{
/**
* Test fitness of visitor.
* @param $type
* @return bool
*/
public function handles($type)
{
return strtolower($type) == 'azure-blob';
}
/**
* @param array $config
* @return \League\Flysystem\Filesystem
*/
public function get(array $config)
{
$endpoint = sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s',
$config['account-name'], $config['api-key']);
$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
$az = new AzureAdapter($blobRestProxy, $config['container']);
return new Flysystem($az);
}
}