Quantcast
Viewing latest article 19
Browse Latest Browse All 20

Updated Wiki: BlobStorage

Working withs Blobs

Resource Model

  • Blobs are web resources (e.g. files) stored on one or more cloud provider datacenters. They follow REST principles (e.g. GET/PUT, ETag, LastModified).
  • They can be read or written.
  • They are grouped into named Containers
  • They have a unique path inside their container. Paths can be a hierarchy of folders
  • Blobs have Metadata (name/value collection pairs), which can be read/written independently of their content.

Configuration

- At minimum you must define your provider connection string. See ConnectionStrings
<configuration><connectionStrings><addname="Azure"providerName="System.StorageModel.WindowsAzure.AzureProvider, Cloud4Net.Azure"connectionString="YourAzureConnectionString"/><addname="AWS"providerName="System.StorageModel.AWS.AWSProvider, Cloud4Net.AWS"connectionString="YourAWSConnectionString"/></connectionStrings></configuration>

- You can also define static blob containers. These containers will be automatically created on startup if they do not already exist.
Warning: container names and blob paths have restrictions of their associated provider (most of the time a container name must comply with a DNS subdomain rules for CDN exposure).
<configuration><configSections><sectionGroupname="system.storageModel"><sectionname="blobs"type="System.StorageModel.Configuration.BlobStorageSection, Cloud4Net.Abstractions"/></sectionGroup></configSections><system.storageModel><!-- specify the default provider for blobs --><blobsdefaultProvider="Azure"><!-- containers registered hereunder will be created on startup if they not already exist --><containername="pictures"/><containername="videos"/><!-- you can assign a different provider to each container (provider attribute) --><containername="cdn-images"provider="AWS"/></blobs></system.storagemodel></configuration>

Code Model

  • You can code against the generic model using IBlobProvider, IBlobContainer and IBlobSpec interfaces:
BlobStorage.Containers["test-container"].Blobs["test-blob"].DeleteIfExist();
  • You can also code against the provider-specific model (AzureProvider, AWSBlobContainer, etc.) to get provider-specific features:
var provider = Storage.GetProvider<AzureProvider>("Azure");
var container = provider.Containers["test-container"];
container.MetaData["data1"] = "value1";
container.UpdateMetaData(); // container metadata feature is specific to Azure Blob Storage

How-to

How-to AzureAWSNTFSCache
Get a specific provider from configurationImage may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Create a blob containerImage may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Delete a blob containerImage may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Does a blob container exists ?Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported
Image may be NSFW.
Clik here to view.
Supported


Get a specific blob provider from config


using System.StorageModel;
var provider = Storage.GetProvider<IBlobProvider>("Name");

Create a blob container


// create the specified container (throws an exception if it already exist)
provider.Containers["container-name"].Create();
// create the specified container (without throwing an exception)
provider.Containers["container-name"].CreateIfNotExist();

Delete a blob container


// delete the specified container (throws an exception if it does not exist)
provider.Containers["container-name"].Delete();
// delete the specified container (without throwing an exception)
provider.Containers["container-name"].DeleteIfExist();

Does a blob container exist ?


// test if the specified container existvar exist = provider.Containers["container-name"].Exist;
implementation note: for performance purpose, the Exist property is evaluated once per container object (e.g. if you test it multiple times on the same object, the provider will not check again). To check multiple time if a container exist, get another reference to the container (by calling providers.Containers["container-name"] again)

Viewing latest article 19
Browse Latest Browse All 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>