API reference for blob storage
The Sitecore Azure Blob Storage module consists of the following assembly:
-
Sitecore.Framework.Data.Blobs- provides theAzureStorageBlobProviderclass, which allows APIs to work with blob storage.
Sitecore exposes a BlobStorage API to include the underlying blob providers (for example, AzureStorageBlobProvider), and provides convenient APIs to work with blob storage. By default, the BlobStorage API consists of the following assemblies:
-
Sitecore.Framework.Data.Blobs.Abstractions- provides abstractions to implement blob providers for the Sitecore Blob Storage module. -
Sitecore.Framework.Data.Blobs- provides convenient APIs so you can work with blob storage without having to know about the blob providers configured in Sitecore.
BlobStorage APIs
BlobStorage APIs
The databases in Sitecore can use one or more storage for blob storage. In Sitecore, the Database.BlobStorage property includes a list of blob providers that work with the Sitecore databases. The property also lists APIs that you can use to work as extension methods with blob storage, without having to know about the blob providers configured in Sitecore.
Use the following code to access BlobStorage in Sitecore:
The following class name examples demonstrate how to use the Sitecore APIs from BlobStorage extensions:
|
Method |
|
|
Description |
Use this API with the Blob ID to check whether a a blob exists in a Blob Storage account. |
|
Example |
|
|
Method |
|
|
Description |
Use this API with the Blob ID to get a specific blob from Blob Storage. |
|
Example |
|
|
Method |
|
|
Description |
Use this API with the Blob ID to remove the blob from Blob Storage. |
|
Example |
|
|
Method |
|
|
Description |
Use this API with the Blob ID to save the blob in Blob Storage. |
|
Example |
|
Remove orphaned blobs
Remove orphaned blobs
Sitecore's blob storage garbage collection feature helps you delete orphaned blobs from Sitecore. Initiate the deletion by using the following method: Sitecore.Data.DefaultDatabase.BlobStorage.CleanupOrphanBlobs.
For example:
AzureStorageBlobProvider APIs
AzureStorageBlobProvider APIs
There are a few different ways you can access the blob provider directly, if necessary:
-
Example 1:
-
Example 2:
-
Example 3:
This following class name examples demonstrate how to use the Sitecore APIs from BlobProvider methods:
|
Method |
|
|
Description |
Use this API with the Blob ID to check whether the blob exists in Blob Storage. |
|
Example |
|
|
Method |
|
|
Description |
Use this API with the Blob ID to get a specific blob from Blob Storage. |
|
Example |
|
|
Method |
|
|
Description |
Use this API with the Blob ID to remove a blob from Blob Storage. |
|
Example |
|
|
Method |
|
|
Description |
Use this API with the Blob ID to save a blob in Blob Storage. |
|
Example |
|
Extend AzureStorageBlobProvider APIs
Extend AzureStorageBlobProvider APIs
You can extend blob provider methods, for example, if you want to extend the GetBlob API:
Create a new BlobProvider
Create a new BlobProvider
You can create your own blob providers by using the Sitecore.Framework.Data.Blobs.Abstractions APIs, for example, if you want to create an InMemoryBlobProvider API: