HBLL-Collection-Development/omeka-s-any-cloud

View on GitHub
src/Service/File/Store/AzureFactory.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace AnyCloud\Service\File\Store;

use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
use MicrosoftAzure\Storage\Blob\BlobRestProxy;

class AzureFactory extends AbstractFlysystemFactory
{
    protected function getConfigKey(): string
    {
        return 'azure';
    }

    protected function getFilesystemAdapter(array $config): FilesystemAdapter
    {
        $connectionString = sprintf(
            'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;',
            $config['account_name'],
            $config['account_key']
        );
        $client = BlobRestProxy::createBlobService($connectionString);
        $adapter = new AzureBlobStorageAdapter($client, $config['container_name']);

        return $adapter;
    }
}