Johan Björnfot
Aug 21, 2014
  6374
(7 votes)

LocalMediaProvider

In the nuget package EPiServer.CMS.Core.7.13.0 is a new service IdentityMappingService introduced. The purpose of the service is to support external integrations (like a content provider or an asset importer) to manage a mapping between the external identity and the content references and GUID:s used in EPiServer CMS to ensure that any links that exists or are created with this data, always reference the same external content. The external identifier should be of type Uri (which can be built from for example guid, int, string etc).

To test this new service I built a custom content provider called LocalMediaProvider. The idea is that it maps a local file system (like your harddrive) into the asset gadget in EPiServer CMS. It’s similar to the VirtualPathNativeProvider that existed in previous versions of EPiServer.

Easiest way to integrate the local files would be to create a folder under GlobalAssetsRoot and set the entry point for the provider to that folder. However in my case I wanted to distinguish the local files from other files so I created the entry point outside the asset root. And instead registered an UI component so the local files appears as a separate "tab" in the asset panel. If you try the code and the tab does not show up try to go to "My settings" and select "Reset Views" under "Display options".

When going in to the media gadget you can see your local folder structure. In my case I set “C:\” when configuring my provider, in reality you would probably point out a folder structure with for example images.  
Localmediagadget

If you want to try it out the source code is located in https://github.com/jbearfoot/LocalMediaProvider. There you will also find a built nuget package that you can add to your project. It will then include the code to your project in a folder LocalMediaProvider.

Note that this was just a sample I wrote to test the IdentityMappingService and hence it is not “productified” and all usage of the code is at own risk Blinkar. The code consists of three components. First there is a content provider that reads files and folders from the local file system and presents them as ContentFolders and IContentMedia instances. Then there is a UI component that registers a “new” tab in the media gadget. And finally a Initialization module that creates an entry point for the provider, registers the provider and registers some routes for the media.

Aug 21, 2014

Comments

Aug 21, 2014 10:28 AM

Great! Started a concept for this but the headache was to be able to have an identifier in the path!

Arild Henrichsen
Arild Henrichsen Aug 21, 2014 02:33 PM

This is great. Several customers are requesting a better way to integrate external file systems with EPiServer.

Aug 21, 2014 04:30 PM

Nice work. :)

Aug 21, 2014 05:52 PM

This is awesome!

valdis
valdis Aug 26, 2014 04:35 PM

Awesome :)

valdis
valdis Aug 27, 2014 10:13 PM

When it will be built-in? :)

Sep 5, 2014 09:44 PM

Regarding builtin that is up to our Product Managers to decide.

Luc Gosso (MVP)
Luc Gosso (MVP) Feb 25, 2015 02:03 PM

This was long awaited! Great! but your project does not work with paths that have white space in folders or files. How to solve that? any idea?

Answer:I have to replace with -, also @åäö chars has to be removed or replaced!

Luc Gosso (MVP)
Luc Gosso (MVP) Apr 15, 2015 08:51 AM

Hi Johan, by default, shouldn't the /thumbnail work in UI list?
Also, upload, delete functionality is that posible to add, is it? (before i start implementing)

May 26, 2015 09:08 AM

I'm not sure why, but in my environment the casing for mappedFilesystemItems Uri differs from the ExternalIdentifier, resulting in .First doesn't return anything and a exception being thrown. I solved this the quick, and perhaps ugly, way:

var mappedIdentities = _identityMappingService.List(mappedFileSystemItems.Select(f => f.Uri), true)
.Select(m => new
{
  MappedId = m,
  Path = mappedFileSystemItems.FirstOrDefault(i => i.Uri.ToString().ToLower().Equals(m.ExternalIdentifier.ToString().ToLower())).Path
});

camilla nyberg
camilla nyberg Sep 28, 2016 11:11 AM

Bump on the "Also, upload, delete functionality is that posible to add, is it? (before i start implementing)". Luc Gosso, did you implement it ? 

Andreas Nicolaisen
Andreas Nicolaisen Sep 30, 2016 03:52 PM

@camilla nyberg: There is some new stuff in the cms 9 branch: https://github.com/jbearfoot/LocalMediaProvider/tree/cms9

Please login to comment.
Latest blogs
Opti ID overview

Opti ID allows you to log in once and switch between Optimizely products using Okta, Entra ID, or a local account. You can also manage all your use...

K Khan | Jul 26, 2024

Getting Started with Optimizely SaaS using Next.js Starter App - Extend a component - Part 3

This is the final part of our Optimizely SaaS CMS proof-of-concept (POC) blog series. In this post, we'll dive into extending a component within th...

Raghavendra Murthy | Jul 23, 2024 | Syndicated blog

Optimizely Graph – Faceting with Geta Categories

Overview As Optimizely Graph (and Content Cloud SaaS) makes its global debut, it is known that there are going to be some bugs and quirks. One of t...

Eric Markson | Jul 22, 2024 | Syndicated blog

Integration Bynder (DAM) with Optimizely

Bynder is a comprehensive digital asset management (DAM) platform that enables businesses to efficiently manage, store, organize, and share their...

Sanjay Kumar | Jul 22, 2024

Frontend Hosting for SaaS CMS Solutions

Introduction Now that CMS SaaS Core has gone into general availability, it is a good time to start discussing where to host the head. SaaS Core is...

Minesh Shah (Netcel) | Jul 20, 2024

Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024