using System;
using Azure.Storage.Blobs;

namespace squirrowse.db
{
    public class Bloob
    {
        private readonly BlobServiceClient _blobServiceClient;

        public BlobContainerClient Container;

        public Bloob()
        {
            _blobServiceClient =
                new BlobServiceClient(
                    "DefaultEndpointsProtocol=https;AccountName=squirrowse;AccountKey=/S09Er70NmQ6vNwJU0eVG0pbV5DklBx8vdp4M28dEfr0ZRmSzd5B/STrzDTfkbxg4BcN+rRu93pRowC/4Ys48A==;EndpointSuffix=core.windows.net");
            Container = CreateImgBloob("squirrowseimg");
        }

        private BlobContainerClient CreateImgBloob(string name)
        {
            try
            {
                return _blobServiceClient.CreateBlobContainer(name);
            }
            catch (Exception)
            {
                return _blobServiceClient.GetBlobContainerClient(name);
            }
        }
    }
}