Try our conversational search powered by Generative AI!

Per Magne Skuseth
Apr 1, 2014
  11964
(6 votes)

SQL Blob Provider: Store your blobs in the database

A new package is available on the EPiServer nuget feed: EPiCode.SqlBlobProvider. This is a blob provider that enables storing of blobs in the database, rather than on disk.

Why is this useful?

  • Perfect for load balanced environments, as you will not need a file share or similar to handle distribution of files between servers
  • Great for development teams who share a database
  • Easier to deploy: No need to copy blob files when doing a deploy or migration to another environment. No need of putting them in source control either for that matter
  • When you bring back the database from production to your development environment for that next feature you're doing, you get all the files too
  • Should also work fine for EPiServer Commerce

 

Installation

Install the NuGet package, and your are good to go. EPiServerFramework.config should be automatically transformed with the correct blob provider settings. If you need to change it manually, simply add the following to EPiServerFramework.config:

<blob defaultProvider="sqlBlobProvider">
  <providers>
    <add name="sqlBlobProvider" type="EPiCode.SqlBlobProvider.SqlBlobProvider, EPiCode.SqlBlobProvider" />
  </providers>
</blob>

Migration

If you are installing the SqlBlobProvider in an existing project that already uses the standard file blob provider, you will need to convert existing FileBlobs into SqlBlobs. This can easily be done with EPiCode.BlobConverter, which is another new package in the feed. The package contains a scheduled job (aka. BlobJob), which will convert all file blobs into the currently configured blob type. The conversion tool is not restricted to the SqlBlobProvider, so you could use it for other blob types as well.

Tip: If you are upgrading to EPiServer 7.5, and migrating VPP-based files to the new media system and want to use the SQL blob provider, make sure that the provider is installed prior before running the EPiServer VPP migration tool. This way, the VPP-files will be directly migrated to SQL blobs.

 

This is an open source module and full source code is available on EPiCode: 

https://www.coderesort.com/p/epicode/browser/EPiCode.SqlBlobProvider

Apr 01, 2014

Comments

K Khan
K Khan Apr 1, 2014 02:59 PM

In E-Commerce website performance is always a question. I am wondering, has this been tested with EPiServer Commerce? or any stress test has been carried out?

Gayathri Saravanan
Gayathri Saravanan Apr 2, 2014 09:23 AM

Simply superb

Per Magne Skuseth
Per Magne Skuseth Apr 2, 2014 11:56 AM

We've done stress tests, and with good results. But of course, projects may vary a lot and you should perform your own stress tests as well.

Fredrik Stolpe
Fredrik Stolpe Apr 2, 2014 06:05 PM

Super, works great!

Thanks

Arild Henrichsen
Arild Henrichsen Apr 3, 2014 10:24 PM

+1 for BlobJob

Apr 25, 2014 06:26 AM

Nice, thanks a lot

I was expecting the default BlobProvider in EPiServer to be "databased" but realized that it wasn't after reading the documentation. Thought for a short while, ok, have to build one. Then I found your post.

Regards Hans

Kevin Hayman
Kevin Hayman Jun 13, 2014 01:11 AM

Should files stored in the database be indexed using the standard EPiServer search? We've built a search page using the standard EPiServer search but files are not returned in the search results if we search the contents of the file.
If we remove the SqlBlob provider the documents (pdf, Word etc.) are returned when we search based on contents of the file.
I'd like to keep using the SqlBlob provider if we can but will have to resort back to the file system if we can't.
Thanks.

Andrew Kiss
Andrew Kiss Apr 15, 2015 04:13 AM

Has anyone experienced the following issue using the BlobConverter?

My blobs are currently within the project

Converting errors:442. Details:System.IO.IOException: The process cannot access the file 'C:\Development\www\WWWEPiServer\App_Data\blobs\0235a8aa47404d0c990ad7b95b56cc02\120616001c21450392ab33dcac6a9e22.png' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at EPiServer.Framework.Blobs.FileBlob.OpenWrite() at EPiServer.Framework.Blobs.FileBlob.Write(Stream data) at EPiCode.BlobConverter.BlobJob.ProcessFile(String path, String directory) System.IO.IOException: The process cannot access the file 'C:\Development\www\WWWEPiServer\App_Data\blobs\0235a8aa47404d0c990ad7b95b56cc02\120616001c21450392ab33dcac6a9e22_Thumbnail.png' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at EPiServer.Framework.Blobs.FileBlob.OpenWrite() at EPiServer.Framework.Blobs.FileBlob.Write(Stream data) at EPiCode.BlobConverter.BlobJob.ProcessFile(String path, String directory) System.IO.IOException: The process cannot access the file 'C:\Development\www\WWWEPiServer\App_Data\blobs\0346c5e95ef44252b7516fdd591d5362\c5db0c04e4774cea9896c77b95221fbe.png' because it is being used by another process. a

Thanks

Johan Kronberg
Johan Kronberg Jun 25, 2015 03:23 PM

Andrew: NuGet package adds the provider config to EPiServerFramework.config but if you got a late EPi that section resides in web.config. I got the same error as you but when I copied the blob config to in Web.config and removed EPiServerFramework.config it worked.

Madis Vellamäe
Madis Vellamäe Nov 10, 2016 11:10 AM

Nice post! Thanks to your source code I'm now able to write my own BlobProvider in order to use MongoDB GridFS and ImageResizer!

However, regarding your current implementation, I must warn that DDS is extremely slow if there are more than 20k rows. We have a commerce site with more than a million images (including thumbnails) and it would take over 30 seconds to get a single image out of DDS.

But once again, great job!

Please login to comment.
Latest blogs
New Series: Building a .NET Core headless site on Optimizely Graph and SaaS CMS

Welcome to this new multi-post series where you can follow along as I indulge in yet another crazy experiment: Can we make our beloved Alloy site r...

Allan Thraen | Jun 14, 2024 | Syndicated blog

Inspect In Index is finally back

EPiCode.InspectInIndex was released 9 years ago . The Search and Navigation addon is now finally upgraded to support Optimizely CMS 12....

Haakon Peder Haugsten | Jun 14, 2024

Change the IP HTTP Header used for geo-lookup in Application Insights

.

Johan Kronberg | Jun 10, 2024 | Syndicated blog

Copying property values

In this article I’d like to show simple Edit Mode extension for copying property values to other language versions. In one of my previous blogposts...

Grzegorz Wiecheć | Jun 8, 2024 | Syndicated blog

Auto-translate with OpenAI GPT-4o in Optimizely CMS

Improvements for Episerver.Labs.LanguageManager! It's now possible to auto-translate both a page and its children at the same time! Additionally, m...

Tomas Hensrud Gulla | Jun 7, 2024 | Syndicated blog

Upgrade To Optimizely CMS 12 Issue: List item fields have become Required

There are many funny details to be aware of when upgrading from Episerver CMS 11 to Optimizely CMS 12. One of them that might feel a bit confusing ...

Allan Thraen | Jun 7, 2024 | Syndicated blog